Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.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 3.x 解析循环python中的过时元素_Python 3.x_Selenium Webdriver - Fatal编程技术网

Python 3.x 解析循环python中的过时元素

Python 3.x 解析循环python中的过时元素,python-3.x,selenium-webdriver,Python 3.x,Selenium Webdriver,我正在编写一个python脚本来循环抛出行,并对每行执行一个操作—一个简单的双击和授权。它对于第一行非常有效,但是当它到达第二行时,它抛出一个“stale元素引用:元素未附加到页面文档” 现在,我了解到问题在于,在我对第一行执行操作后,网页会刷新,因此即使第二行在那里,它也不再处于活动状态 我只是不知道该怎么解决这个问题。如果有人能提供一些意见,我将不胜感激 #capture the rows tables = driver.find_elements_by_xpath("//table[sta

我正在编写一个python脚本来循环抛出行,并对每行执行一个操作—一个简单的双击和授权。它对于第一行非常有效,但是当它到达第二行时,它抛出一个“stale元素引用:元素未附加到页面文档”

现在,我了解到问题在于,在我对第一行执行操作后,网页会刷新,因此即使第二行在那里,它也不再处于活动状态

我只是不知道该怎么解决这个问题。如果有人能提供一些意见,我将不胜感激

#capture the rows
tables = driver.find_elements_by_xpath("//table[starts- 
with(@id,'revalgridview') and contains(@class,'x-grid-item')]")

#loop through each row
for row in tables: 

        time.sleep(5)

        # check user who made the changes
        authorizations = row.find_elements_by_tag_name('td')[1].text

        if authorizations == "TCCCOPS_DC" or authorizations == "TCCCOPS_RC": 
              actionChains = ActionChains(driver)
              actionChains.double_click(row).perform()
              time.sleep(3)

              #click authorize button 
              auth = driver.find_element_by_xpath("//span[contains(text(),'Authorize')]")
              auth.click()
              time.sleep(5)

       else:
              continue

在执行线程时,数据集似乎已更改。您对行使用了错误的定位器,请以文本格式共享HTML。单击“授权”后页面是否重定向到另一个?在执行线程上睡眠时,数据集似乎已更改。您对行使用了错误的定位器,请以文本格式共享HTML。单击后页面是否重定向到其他页面?