driver.execute_script(script)
输入账号
driver.find_element_by_id(‘J-userName’).send_keys(‘123@163.com’)
输入密码
driver.find_element_by_id(‘J-password’).send_keys(‘xxxxxxx’)
点击登陆
driver.find_element_by_id(‘J-login’).click()
等待2秒钟,不要点的太快,以免被识别或者以免网页加载跟不上。
time.sleep(2)
滑动
定位 滑块标签
span = driver.find_element_by_id(‘nc_1_n1z’)
actions = ActionChains(driver) # 行为链实例化
time.sleep(2) # 等待2秒钟
经截图测量,滑块需要滑过的距离为300像素
actions.click_and_hold(span).move_by_offset(300, 0).perform() # 滑动
解决浏览器识别
其中的以下这几行代码,可用去除浏览器对selenium的识别,如图可以使浏览器页面不再显示图中“Chrome正受到自动测试软件的控制”字样。
from selenium.webdriver import ChromeOptions
option = ChromeOptions()
option.add_experimental_option(