I am trying to click an element using javascript (this is for selenium robot framework script). But it is throwing an error
unknown error: Runtime.evaluate threw exception: SyntaxError: missing ) after argument list)
Can you please help me correct my statement.
Execute Javascript -->>
document.evaluate('\\span[text()='Participant']', document, null, FIRST_ORDERED_NODE_TYPE, null).click()
As you can see in the above statement, I want javascript to click element that has 'Participant' text (the xpath doesn't have any id or any other attributes except text). If I have made any errors in the code/statement, can you please help me write the correct code/statement.
There are so many mistakes in your javaScript
:-
xPath
start with /
which means Selects from the root node or //
which means Selects nodes in the document from the current node that match the selection no matter where they are
if you are using ''
for whole xpath
as string then use ""
to other string inside xpath
expression, or using ""
for whole xpath
as string then use ''
for other string inside xpath
expression
read Document.evaluate()
syntax how to use it in javascript
.
So after all of these point you should try as below with correct javascript
:-
document.evaluate("//span[text()='Participant']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotItem(0).click();
Hope it will help you..:)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.