Selenium Python执行JavaScript单击链接时出错。我想我的语法错了

Selenium Python执行JavaScript单击链接时出错。我想我的语法错了,javascript,python-2.7,selenium,selenium-webdriver,Javascript,Python 2.7,Selenium,Selenium Webdriver,我正在尝试单击我们网页上的链接。该页面是从GWT构建的。 我正在使用Selenium Python中的JavaScript执行 self.driver.execute_script("document.gElementById('tab_administration').click()") 我在运行代码时遇到以下错误: File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 181

我正在尝试单击我们网页上的链接。该页面是从GWT构建的。 我正在使用Selenium Python中的JavaScript执行

self.driver.execute_script("document.gElementById('tab_administration').click()")
我在运行代码时遇到以下错误:

File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 181, in check_response
raise exception_class(message, screen, stacktrace)
WebDriverException: Message: JavaScript error
我的代码片段是:

     def click_administration(self):
        time.sleep(10)
        #self.driver.find_element(By.ID, 'tab_administration').click()
        self.driver.execute_script("document.gElementById('tab_administration').click()")
        #wait = WebDriverWait(self.driver, 10)
        #element = wait.until(EC.element_to_be_clickable((By.ID, 'tab_administration')))
        #element.click()
        return AdministrationPage(self.driver)
我的JavaScript调用语法不正确吗?为什么会失败

在Firefox开发工具中,它可以工作。在控制台窗口中,我输入以下代码行:

document.gElementById('tab_administration').click()";
我正在尝试driver.execute_脚本,因为当我尝试WebDriverWait(self.driver,10)时,会出现超时异常

谢谢你的帮助。谢谢

Riaz

试试这个:

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

那太棒了,很管用。已单击“管理”选项卡。谢谢。这是我使用的代码。admin\u tab=self.driver.find\u元素(By.ID,'tab\u administration')self.driver.execute\u脚本(“参数[0]。单击()”,admin\u选项卡)