I\'ve got an issue with browser.execute_script while using selenium with python. There is an element that i\'d like to click (it\'s xpath below)
\"//*[@id=\'lis
The correct way to execute a script is to actually write a JavaScript script!.
The click()
function of selenium is on the element of the DOM you have located not a script.
As @Andersson suggested try browser.execute_script('arguments[0].click();', navMenu)
I can see you added a sleep for 3 seconds... Using Selenium we generally use WebDriverWait
you can learn more about wait's here.
If it's too complicated you can just start with driver.implicitly_wait(3)
instead of sleep.
Edit:
If the Element is not displayed yet you can just use navMenu.is_displayed()
Hope this helps you.