我用chromedriver进行了selenium webdriver测试.虽然我可以在使用Chrome浏览器时成功运行测试,但我无法在无头模式下运行相同的测试.
我无法处理Js警报.实际上,当拍摄屏幕截图时,似乎警报甚至不会弹出.
我尝试了几种解决方法:
1)driver.window_handles- >似乎没有其他窗口存在
2)driver.execute_script("window.confirm = function(){return true;}")- >该脚本没有任何改变
3)element = WebDriverWait(driver, 20).until(EC.alert_is_present())当然是明确的等待
在浏览器模式下我使用普通:
try:
print driver.switch_to.alert.text
driver.switch_to.alert.accept()
except NoAlertPresentException as e:
print("no alert")
Run Code Online (Sandbox Code Playgroud)
其他人在无头模式下遇到此问题的警告?
selenium-chromedriver selenium-webdriver google-chrome-headless
在我的Selenium-Test(有chromedriver-2.24)中,我试图通过基本身份验证访问我的网页,并使用以下语句:
WebDriver driver = ...;
driver.get("http://admin:admin@localhost:8080/project/");
Run Code Online (Sandbox Code Playgroud)
但谷歌Chrome在控制台中给出了以下警告:
[弃用]其URL包含嵌入凭据(例如
https://user:pass@host/)的子资源请求被阻止.有关详细信息,请参阅https://www.chromestatus.com/feature/5669008342777856.
在标记的链接中提到支持被删除:
在子资源请求中删除对嵌入式凭据的支持.(已删除)
我现在的问题是,还有另一种从Selenium进行基本身份验证的方法吗?
java selenium google-chrome basic-authentication selenium-webdriver
我试图在提示符(URL Given)中输入数据,下面的代码给我一个错误.请帮我解决这些问题?
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Firefox()
url = "http://the-internet.herokuapp.com/basic_auth"
driver.get(url)
time.sleep(5)
alert = driver.switch_to.alert
alert.authenticate('admin','admin')
time.sleep(4)
alert.accept()
Run Code Online (Sandbox Code Playgroud)
我尝试过:
ActionChains(driver).send_keys("admin").send_keys(Keys.TAB).send_keys("admin").perform()
Run Code Online (Sandbox Code Playgroud)
这个也行不通.
python selenium windows-authentication basic-authentication selenium-webdriver