0
我想运行一个python脚本,它将继续点击加载更多按钮,直到它消失。而我试图代码如下所示:这里元素不可点击硒python
import csv
import time
import re
from bs4 import BeautifulSoup
from selenium.common.exceptions import NoSuchElementException
from selenium import webdriver
import requests
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
page=requests.get('https://www.killerfeatures.com/mobile/brands').content
soup1=BeautifulSoup(page,"html5lib")
brndsbox=soup1.find_all("div",attrs={"class":"brndsbox"})
count=0
brand_link=[]
for each in brndsbox:
x= each.find("span")
j=str(x).split('=')[5].split('"><')[0].replace('"',"")
brand_link+=["https://www.killerfeatures.com"+j]
chromedriver=r"D:\MOBILE_JUNE_22_2017\old_files_\price raja mobile\working\chromedriver.exe"
driver=webdriver.Chrome(chromedriver)
for url in brand_link:
print url
driver.get(url)
track_count=0
while True:
try:
element = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "loadMoreRecords")) )
element.click()
print "click", track_count
time.sleep(5)
track_count+=1
except NoSuchElementException:
break
print "complete"
问题是,它是示值误差为selenium.common.exceptions.WebDriverException: Message: unknown error: Element is not clickable at point (636, 583)
它为什么发生任何想法。我已经使用了一个明确的等待,直到元素可见。在那之后,我也遇到了错误。提前致谢!
任何问题的代码? –
代码运行良好,但进入无限循环。它不断点击,虽然元素不存在。不知道为什么会发生 –