Error while entering a text in a input box in tricentis Tosca - tosca

I'm trying to add a text into input box in tricentis tosca. But the webpage throws an error something like :
Message from webpage:
The value "[123456, function(callback/, thisArg/*] {
VarT,K.....
I treid using SENDKEYS and USERSIMULATION even then i couldn't avoid this error.

Related

RSelenium StaleElementReference error in lapply

I am trying to scrape a link with Rselenium. Sometimes--only sometimes and this is not replicable (cause when I re-run the code, the problem disappear)--the programme gives me an error as follows:
Error: Summary: StaleElementReference
Detail: An element command failed because the referenced element is no longer attached to the DOM.
class: org.openqa.selenium.StaleElementReferenceException
Further Details: run errorDetails method
I think this is because I clicked on a web element and the DOM is somehow modified after a click (see this answer: RSelenium throwing StaleElementReference error). In this case, my code is to click on all the "expand" arrow of a weblink so show the full text. But the click under concern here is wrapped in a sapply function as follows, so I cannot relocate the web element every time:
arrow = remDr$findElements(using = 'class', value = "WB_text_opt") #locate the arrows
sapply(arrow, function(x){
Sys.sleep(0.15)
x$clickElement()
}) # click on them
remDr$findElement('css', 'html')$sendKeysToElement(list(key = "end")) # scroll the webpage down
The selenium reference of the items in the arrow list will be refreshed when you click on the arrow list item in your function. That's the reason why your are getting the staleElementException. Please get the specific element in the loop using the xpath/get the elements and then point to specific arrow item using the index and then click on it.
sapply(arrow, function(x){
Sys.sleep(0.15)
x$clickElement() #<== This line will work only for the first iteration.
# you will get issue from the 2nd item as the element references
# updates, when you click on 1st item.
# Try using something like .findElements()[index]
})

R Error: unexpected ',' in "write(txt2, file = ("C:/Users/User/Documents/html","

I received this error when exporting html into text. I dont really understand what cause this. Please help me with it. Thank you in advanced
Error: unexpected ',' in " write(txt2, file = ("C:/Users/User/Documents/html","
to export converted html in text.
Below is my code in R:
write(txt2, file = ("C:/Users/User/Documents/html", txt2.txt))
the objective is to convert html webpage into text and export it into working directory using R.
The last line of code is causing this error which i don't know why.

DT::datatable(iris) gives error in console "Failed to load resource: A server with the specified hostname could not be found."

(I could not see a tag for "r DT")
I've used datatable many times before. What appears like out of the blue, any tables I created using datatable now won't render.
Taking the simplest example from documentation:
library(DT)
datatable(iris)
In R Studio a blank viewer pane in all white is displayed. When I look in the console I see an error message:
Failed to load resource: A server with the specified hostname could not be found.
packageVersion("DT")
[1] ‘0.2’
Here's are screen shots of my rstudio:
Blank viewer pane:
And after I right click on inspect element and view the console tab (not sure if this is relevant or not):
Does anyone know how I can get DT to render my datatables?

RSelenium: Find link with Xpath

I want to find all links to PDF files in a page with RSelenium and Xpath.
Please consider
require(RSelenium)
RSelenium::checkForServer()
RSelenium::startServer()
remDr <- remoteDriver()
remDr$open()
remDr$navigate("https://cran.r-project.org/manuals.html")
In the page there are multiple links to PDF files such as
PDF
But my first try
remDr$findElement(using = "xpath", "//a[contains(#href,'.pdf')/#href")
produces the following error
Error: Summary: InvalidSelector
Detail: Argument was an invalid selector (e.g. XPath/CSS).
class: org.openqa.selenium.InvalidSelectorException
Am I getting the syntax wrong?
There is a syntax error inside your expression, missing a closing ]:
//a[contains(#href,'.pdf')]/#href
HERE^
But, even if you fix it, you'll get an error - a different one this time. This is because XPath expressions in selenium have to point to web elements and not element attributes. In other words, use //a[contains(#href,'.pdf')] to find an element and then get_attribute method to get the href attribute value.
Note that you may also find the link by link text:
remDr$findElement(using = "link text", "PDF")

Cannot get verbose=FALSE working for "joinCountryData2Map"

I am using 'R Presentation' from R Studio to create a slide show for my project. I am using the below code and whatever I do I am not able to get rid of the output message from the code. I do not want the progress message to be included in my presentation slide.
I have the below portion of code in a different chunk , but that did not help me either. I cleared cache and tried all stuffs, but could not get rid of the progress message.
Any idea how to get rid of the output message ?
sPDF <- joinCountryData2Map(subset(world_all, year==year.list[i]),joinCode = "ISO3 ,nameJoinColumn = "country_code" , mapResolution = "coarse",verbose=FALSE)
it generates below output message , which I do not want to show in my presentation slide
154 codes from your data successfully matched countries in the map 0
codes from your data failed to match with a country code in the map 90
codes from the map weren't represented in your data
That did not work either.
Then I went to the source code of that function and found that a "cat" command is being used to print the messages. So, I muted the cat command output using the below method , and it worked !!
capture.output( 'the whole function' , file='NUL' )
Yes; verbose=BOOL controls whether or not the progress messages are printed, not the final message. I'd suggest experimenting with wrapping the call in a call to suppressMessages, and seeing what happens.

Resources