Reputation: 395
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;")
Upvotes: 0
Views: 213
Reputation: 474003
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:
Upvotes: 2