【发布时间】:2021-10-08 08:12:08
【问题描述】:
我已经看到有关此错误的其他问题,但我的情况是在我的程序中,其他元素应该收到点击。详细信息:网络驱动程序正在通过谷歌搜索滚动,它必须点击它找到的每个网站,但程序阻止了这一点。我怎样才能让它不搜索它点击的上一个网站?
这就是函数。程序正在循环它,在第一个循环之后它向下滚动并发生错误:
def get_info():
browser.switch_to.window(browser.window_handles[2])
description = WebDriverWait(browser, 10).until(
EC.presence_of_element_located((By.TAG_NAME, "h3"))
).text
site = WebDriverWait(browser, 10).until(
EC.presence_of_element_located((By.TAG_NAME, "cite"))
)
site.click()
url=browser.current_url
#removes the https:// and the / of the url
#to get just the domain of the website
try:
link=url.split("https://")
link1=link[1].split("/")
link2=link1[0]
link3=link2.split("www.")
real_link=link3[1]
except IndexError:
link=url.split("https://")
link1=link[1].split("/")
real_link=link1[0]
time.sleep(3)
screenshot=browser.save_screenshot("photos/"+"(" + real_link + ")" + ".png")
global content
content=[]
content.append(real_link)
content.append(description)
print(content)
browser.back()
time.sleep(5)
browser.execute_script("window.scrollBy(0,400)","")
time.sleep(5)
【问题讨论】:
标签: python python-3.x selenium selenium-webdriver automation