gpt4 book ai didi

java - 使用 selenium 时,网站上不会出现登录失败消息

转载 作者:太空宇宙 更新时间:2023-11-04 10:57:15 25 4
gpt4 key购买 nike

我正在尝试使用selenium登录网站。如果我输入错误的凭据并提交登录表单(没有selenium),最终站点会提供访问拒绝消息。但是当我使用selenium执行相同的操作时,不会出现访问拒绝消息。有什么建议吗?

网址:https://oa.lombardfinance.com.au/

    ChromeOptions options = new ChromeOptions();
options.addArguments("disable-infobars");
WebDriver driver = new ChromeDriver(options);
JavascriptExecutor js = (JavascriptExecutor)driver;
driver.get("https://oa.lombardfinance.com.au/");
driver.findElement(By.id("ctl00_ContentPlaceHolder1_txtClientNumber")).sendKeys("Subrat");
driver.findElement(By.id("ctl00_ContentPlaceHolder1_txtPassword")).sendKeys("Subrat");
driver.findElement(By.id("ctl00_ContentPlaceHolder1_txtCaptcha")).sendKeys("Subrat");
//WebElement loginForm = driver.findElement(By.id("aspnetForm"));
//js.executeScript("arguments[0].submit();", loginForm);

WebElement login = driver.findElement(By.id("ctl00_ContentPlaceHolder1_btnLogin2"));
new Actions(driver).moveToElement(login).click().perform();

最佳答案

刚刚尝试了您正在使用的相同代码,但驱动程序启动方面略有不同:

System.setProperty("webdriver.chrome.driver", "\path\to\chromedriver.exe");
WebDriver driver = new ChromeDriver();

我排除了这一行: options.addArguments("disable-infobars");Selenium 测试也显示访问被拒绝。

关于java - 使用 selenium 时,网站上不会出现登录失败消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47241308/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com