模拟鼠标轮加载所有元素。
我搜索了谷歌,尝试了很多次,但都失败了。
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
# Configuration information
email = "*******"
password = "*******"
driver = webdriver.Chrome()
index_url = "https://quip.com/"
driver.get(url=index_url)
driver.find_element_by_xpath('//*[@id="header-nav-collapse"]/ul/li[9]/a').click() # click login
time.sleep(1)
driver.find_element_by_xpath('/html/body/div[2]/div[1]/div[1]/form/div/input').send_keys(email) # input email
driver.find_element_by_xpath('//*[@id="email-submit"]').click()
time.sleep(1)
driver.find_element_by_xpath('/html/body/div/div/form/div/input[2]').send_keys(password) # input password
driver.find_element_by_xpath('/html/body/div/div/form/button').click()
time.sleep(2)
拉下卷轴
js="var q=document.documentElement.scrollTop=100000" driver.execute_script(js)
time.sleep(3)
driver.maximize_window()
driver.find_element_by_xpath("xpath").send_keys(Keys.DOWN)
js="var q=document.documentElement.scrollTop=10000"
driver.execute_script(js)
以上方法不起作用。
发布于 2019-09-23 07:29:51
要向下滚动网页https://testselenium.quip.com/
直到最后一个条目,您必须为visibility_of_element_located()
引入WebDriverWait,并且可以使用以下Locator Strategies
从#chrome_options.add_experimental_option('useAutomationExtension',从selenium.webdriver.common.by导入from驱动程序,从selenium.webdriver.support.ui导入WebDriverWait,从selenium.webdriver.support导入expected_conditions,as EC chrome_options = webdriver.ChromeOptions() expected_conditions“启用-自动化”),驱动程序= webdriver.Chrome(options=chrome_options,executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe') driver.get("https://quip.com/") WebDriverWait(驱动程序,20).until(EC.element_to_be_clickable((By.CSS_SELECTOR,“.a.btn smhref=‘/帐户/登录’”)).click()WebDriverWait(驱动程序,20).until(EC.element_to_be_clickable((By.CSS_SELECTOR,)"inputname='email'"))).send_keys("187069474@qq.com") driver.find_element_by_css_selector("button#email-submit").click() WebDriverWait(司机,20).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"inputname='password'"))).send_keys("Huangbo1019@") driver.find_element_by_css_selector("button.submit").click() driver.execute_script("arguments.scrollIntoView(true);),20).until(EC.visibility_of_element_located((By.CSS_SELECTOR,"div.nav-inbox-import-title"))))
在这里您可以找到关于What is the difference between the different scroll options?
的相关详细讨论
https://stackoverflow.com/questions/58055018
复制相似问题