Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python selenium execute_脚本出现错误_Python_Selenium Webdriver_Web Scraping - Fatal编程技术网

Python selenium execute_脚本出现错误

Python selenium execute_脚本出现错误,python,selenium-webdriver,web-scraping,Python,Selenium Webdriver,Web Scraping,我正在尝试使用python的selenium包执行Web页面的javascript函数 我想点击行值 <tr bgcolor="#FFFFFF" style="cursor:hand" onmouseover="onmouseoverTR(this)" onmouseout="onmouseoutTR(this)" onclick="clearwsInfo('2015011800017','2015011800017',this);

我正在尝试使用python的selenium包执行Web页面的javascript函数

我想点击行值

<tr bgcolor="#FFFFFF" style="cursor:hand" 
      onmouseover="onmouseoverTR(this)" 
      onmouseout="onmouseoutTR(this)"         
      onclick="clearwsInfo('2015011800017','2015011800017',this);"
      ondblclick='doSelect("auditflowForm","2015011800017");'>   
我试过的代码是

iedriver = 'C:\Users\IEDriverServer.exe'
browser = webdriver.Ie(iedriver)
browser.get   ('http://114.255.167.200:8092/cidasEN/extend/LookAuditflowListAction.do')
browser.execute_script("clearwsInfo('2015011800017','2015011800017',this)")
我犯了个错误

Traceback (most recent call last):
 File "D:\surendra\Neon-WorkSpace\EvidenseData\selinum.py", line 25, in   <module>
  browser.execute_script("clearwsInfo ('2015011800017','2015011800017',this)")
  File "C:\Python27\lib\site- packages\selenium\webdriver\remote\webdriver.py", line 465, in execute_script
  'args': converted_args})['value']
 File "C:\Python27\lib\site- packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
  self.error_handler.check_response(response)
  File "C:\Python27\lib\site-   packages\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
 selenium.common.exceptions.WebDriverException: Message: JavaScript error
回溯(最近一次呼叫最后一次):
文件“D:\surendra\Neon WorkSpace\a\selinux.py”,第25行,在
执行脚本(“clearwsInfo('2015011800017','2015011800017',this)”)
文件“C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py”,第465行,在execute\U脚本中
'args':已转换的_args})['value']
文件“C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py”,第236行,在execute中
self.error\u handler.check\u响应(响应)
文件“C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py”,第192行,在check\u响应中
引发异常类(消息、屏幕、堆栈跟踪)
selenium.common.exceptions.WebDriverException:消息:JavaScript错误

我如何执行函数clearwsInfo

也许您只需单击TR元素,让JavaScript完成其余的工作,就像人工交互一样

iedriver = 'C:\Users\IEDriverServer.exe'
browser = webdriver.Ie(iedriver)
browser.get   ('http://114.255.167.200:8092/cidasEN/extend/LookAuditflowListAction.do')
tr = browser.find_element_by_xpath("//table[@class='font9']//tr[contains(@onclick, 'clearws')]")
tr.click()

我尝试了tr=browser.find_element_by_xpath('//html/body/TABLE/tr')作为层次结构我得到了一个错误raiseexception_类(message,screen,stacktrace)selenium.common.exceptions.NoSuchElementException:消息:无法找到xpath=///html/body/TABLE/trTest此xpath://表[@class='font9']///tr[包含(@onclick,'clearws')]
iedriver = 'C:\Users\IEDriverServer.exe'
browser = webdriver.Ie(iedriver)
browser.get   ('http://114.255.167.200:8092/cidasEN/extend/LookAuditflowListAction.do')
tr = browser.find_element_by_xpath("//table[@class='font9']//tr[contains(@onclick, 'clearws')]")
tr.click()