3

I've check the docs and other forums I haven't found a concrete answer. please find below the code snippet.

def click_hamburger_menu(self):
    _hamburger_menu_ = WebDriverWait(self.driver, 15).until(
                                EC.visibility_of_element_located((
                                By.XPATH, "//*[name()='svg' and @class='site-header__nav-trigger']")))
    self.driver.execute_script("arguments[0].click()", _hamburger_menu_)

Error message:

selenium.common.exceptions.WebDriverException: Message: unknown error: arguments[0].click is not a function
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Zilden
  • 31
  • 1
  • 4
  • The `execute_script` function is apparently looking for a function as its first parameter. What you're passing in is not a function. What exactly are you expecting that call to do? – mypetlion Feb 27 '19 at 22:41
  • 1
    Are you sure you ran the code you posted? The code you posted looks fine. My guess is that you ran `arguments[0].click` (without the `()`s). – JeffC Feb 28 '19 at 16:30
  • 2
    Ironically it ran well when I removed the () , still questioning why – Zilden Feb 28 '19 at 16:42

1 Answers1

-1

Seems you were pretty close. You need to add a ; after the click() method.

So effectively the line of code:

self.driver.execute_script("arguments[0].click()", _hamburger_menu_)

will be:

self.driver.execute_script("arguments[0].click();", _hamburger_menu_)
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352