TA的每日心情 | 无聊 4 天前 |
---|
签到天数: 530 天 连续签到: 2 天 [LV.9]测试副司令
|
1测试积点
使用selenium登录网站时,账号密码输入后,网页弹出error,不知道什么问题?
- import pandas as pd
- from lxml import etree
- from selenium import webdriver
- from selenium.webdriver.common.action_chains import ActionChains
- from selenium.webdriver.common.keys import Keys
- from selenium.webdriver.common.by import By
- from selenium.webdriver.chrome.options import Options
- import time
-
-
- opt = Options()
- opt.add_experimental_option('excludeSwitches', ['enable-automation'])
- opt.add_argument("--referer=http://pss-system.cnipa.gov.cn/sipopublicsearch/portal/uiIndex.shtml")
- opt.add_argument('user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36"')
- driver = webdriver.Chrome(executable_path='chromedriver', options=opt)
- driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument",{...})
- driver.get('http://pss-system.cnipa.gov.cn/sipopublicsearch/portal/uilogin-forwardLogin.shtml')
- driver.implicitly_wait(10)
- username = "lovae0915"
- password = "passwords"
- driver.find_element(By.XPATH, '//*[@id="j_username"]').send_keys(username)
- driver.find_element(By.XPATH, '//*[@id="j_password_show"]').send_keys(password)
- time.sleep(30)
- cookie = driver.get_cookies()
- print(cookie)
- driver.quit()
-
复制代码 运行结果及报错内容
想了解这是由于什么原因出现的问题,以及解决方式或解决思路
|
|