0

Unable to click the linktext using selenium execute_script function

This is what I am tring to do:

self.driver.execute_script("document.getElementByLinktext('Level 1s').click;")

1 Answer 1

2

You are not calling the click() method:

self.driver.execute_script("document.getElementByLinktext('Level 1s').click();")
                                                                   FIX HERE^

Note that you can also locate the element with selenium and then pass it into the script:

link = self.driver.find_element_by_link_text('Level 1s')
self.driver.execute_script("arguments[0].click();", link)

You can also perform the click via selenium directly if applicable:

link.click()

Also related:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.