访问网页时处理Windows安全性

时间:2019-04-04 15:33:21

标签: c# selenium testing automation automated-tests

我正在尝试登录页面以对其进行测试。问题是打开页面时出现“ Windows Scurity”,并且页面只有填满后才会加载。还尝试将凭据放在链接上。

是否可以使某些脚本在此窗口的后台等待并填充?在driver.navigate行之前调用它?

IWebDriver driver = new InternetExplorerDriver();
                driver.Navigate().GoToUrl("https://www.mywebpage.com/loader.aspx");
                //NEVER REACH THIS PART WINDOWS SECURITY
                driver.SwitchTo().Alert().Accept();

对这个问题有解决方案吗?windows security photo

1 个答案:

答案 0 :(得分:0)

您可以查看下面的帮助器方法,该方法将等待弹出/重叠式广告特定的时间,并在重叠式广告出现后立即填充详细信息,并根据重叠式广告的可见性检查模式是否已关闭

public synchronized void anyPop-UpHandler(int timeOut, String name, String pwd) {
        try {
                wait = new FluentWait<WebDriver>(driver).withTimeout(timeOut, TimeUnit.SECONDS).pollingEvery(1,
                        TimeUnit.SECONDS);
                wait.until(ExpectedConditions.visibilityOf("Xpath of Overlay"));
                driver.findElement(By.XPath("Xpath of name input field")).sendKeys(name);
                driver.findElement(By.XPath("Xpath of pwd input field")).sendKeys(pwd);
                driver.findElement(By.XPath("Xpath of ok button")).click();
                wait = new FluentWait<WebDriver>((WebDriver) driver).withTimeout(20, TimeUnit.SECONDS).pollingEvery(1,
                    TimeUnit.SECONDS);
                wait.until(ExpectedConditions.invisibilityOfElementLocated(element));
                }catch(Exception e) {
        }
    }