gpt4 book ai didi

python - 无法单击页面 Selenium python 上的元素

转载 作者:行者123 更新时间:2023-12-01 03:09:27 25 4
gpt4 key购买 nike

我正在尝试使用 python selenium 移动到第 2 页及此页面之外的页面(分页),并为此花费了几个小时。我收到此错误,并且将感谢任何帮助..来自 chromedriver 的错误

is not clickable at point(). Other element would receive the click

到目前为止我的代码:

class Chezacash:
t1 = time.time()
driver = webdriver.Chrome(chromedriver)


def controller(self):
self.driver.get("https://www.chezacash.com/#/home/")
element = WebDriverWait(self.driver, 10).until(
EC.presence_of_element_located((By.CSS_SELECTOR, "div.panel-heading")))
soup = BeautifulSoup(self.driver.page_source.encode('utf-8'),"html.parser")
self.parser(soup)
self.driver.find_element(By.XPATH, "//li[@class='paginate_button active']/following-sibling::li").click()
time.sleep(2)
soup = BeautifulSoup(self.driver.page_source.encode('utf-8'),"html.parser")
self.parser(soup)


def parser(self, soup):
for i in soup.find("table", {"id":"DataTables_Table_1"}).tbody.contents:
date = i.findAll("td")[0].get_text().strip()
time = i.findAll("td")[1].get_text().strip()
home = i.findAll("td")[4].div.span.get_text().strip().encode("utf-8")
home_odds = i.findAll("td")[4].div.findAll("span")[1].get_text().strip()
draw_odds = i.findAll("td")[5].div.findAll("span")[1].get_text().strip()
away = i.findAll("td")[6].div.span.get_text().strip().encode("utf-8")
away_odds = i.findAll("td")[6].div.findAll("span")[1].get_text().strip()
print home

cheza = Chezacash()
try:
cheza.controller()
except:
cheza.driver.service.process.send_signal(signal.SIGTERM) # kill the specific phantomjs child proc # quit the node proc
cheza.driver.quit()
traceback.print_exc()

最佳答案

如果您通过链接文本找到“下一步”按钮,滚动到其 View 中,然后单击:

next_button = self.driver.find_element_by_link_text("Next")
self.driver.execute_script("arguments[0].scrollIntoView();", next_button)
next_button.click()

在导航到该页面之前,我还会最大化浏览器窗口:

self.driver.maximize_window()
self.driver.get("https://www.chezacash.com/#/home/")

关于python - 无法单击页面 Selenium python 上的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43010622/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com