Reputation: 19
I'm having a hard time trying to use Execute Javascript driver.findElement(By.xpath
in Robot Framework
I have no issues updating the value of an element using this JS method below
document.getElementById("Some_ID").value = "Some Value"
Robot can find the document.getElementById
method but can't find the driver.findElement(By.xpath
method
Does anyone know how I would go about using the method/instantiating the driver?
The error I get is this:
WebDriverException: Message: unknown error: driver is not defined
Upvotes: 1
Views: 1189
Reputation: 300
driver.findElement(By.xpath)
is not a Javascript method. It is a method of Selenium.
As you said, javascript only has document.getElementById
method.
If you still want to use xpath with javascript method, use Assign Id To Element
keyword (see more at HERE). It will assign an ID for an xpath locator. Then use that ID in document.getElementById
method
Upvotes: 1