使用Selenium C#在IE中进行SSL证书处理

问题描述 投票:0回答:1

我需要帮助在IE浏览器中使用selenium和C#处理SSL证书。我已经尝试了一些选项,但没有成功。

第一种方法

private static InternetExplorerOptions IeSettings()
        {
            var options = new InternetExplorerOptions();
            options.AddAdditionalCapability(CapabilityType.AcceptSslCertificates, true);
            options.AddAdditionalCapability(CapabilityType.AcceptInsecureCertificates, true);
            options.IgnoreZoomLevel = true;
            options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
            return options;
        }

        public static IWebDriver ieDriver = new InternetExplorerDriver(IeSettings());

使用此设置,我打开页面,我看到:页面不安全警告和抛出的错误是:

目前关注窗口已关闭.OpenQA.Selenium.NoSuchWindowException:当前关注窗口已关闭。

我试着在那里添加Driver.SwitchTo()。Window(Driver.WindowHandles [0]);但是存在相同的错误。

第二次尝试

我尝试点击页面并发出警告。如果页面已打开,请单击显示更多,等待继续按钮然后单击它(页面对象在其他类中定义)

public void AcceptCertificate()
        {
            Driver.Navigate().GoToUrl("page");

            if (SSLpageTitle.Displayed)
            {
                SSLpageMoreInfoButton.Click();
                Driver.Wait.Until(x => SSLButtonGoToPage.Displayed);
                SSLButtonGoToPage.Click();
            }
        }

不幸的是,我收到了错误:

结果消息:无法找到带有css选择器的元素== [id ='invalidcert_mainTitle']

我尝试了不同类型的CCS选择器,它们都没有工作。我使用硒的形式的IE表示非常糟糕,而且它变得越来越糟糕!

任何想法如何通过?

c# selenium internet-explorer ssl-certificate
1个回答
0
投票

目前关注窗口已关闭.OpenQA.Selenium.NoSuchWindowException:当前关注窗口已关闭。

请检查Required Configuration,并确保您已配置它们。

结果消息:无法找到带有css选择器的元素== [id ='invalidcert_mainTitle']

你可以检查this thread

rg.openqa.selenium.NoSuchElementException通常称为NoSuchElementException,它扩展了org.openqa.selenium.NotFoundException,这是一种WebDriverException。

可以在以下两种情况下抛出NoSuchElementException:

  1. 使用WebDriver.findElement(By by)时: //示例:WebElement my_element = driver.findElement(By.xpath(“// my_xpath”));
  2. 使用WebElement.findElement(By by)时: //示例:WebElement my_element = element.findElement(By.xpath(“// my_xpath”));
© www.soinside.com 2019 - 2024. All rights reserved.