使用 Autoit 脚本处理基于 windows 的弹出窗口后,Selenium 脚本失败
Selenium script fails after using Auto IT script to handle windows based pop up
我有一个网站,它通过身份验证 Window 弹出窗口提示输入用户名和密码。所以,我依靠 AutoIt 来处理弹出窗口并且它有效(输入用户名和密码)。
验证凭据后,我网站的主页将在 10-15 秒的时间间隔内打开。
这是我正在做的事情:
class Class1
{
FirefoxDriver d;
static void Main(string[] args)
{
d = new FirefoxDriver();
d.Manage().Window.Maximize();
d.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(60);
d.Url = "www.example.com";
Process.Start(@"C:\Users\Documents\AutoIt Scripts\Authentication_FireFox.exe");
//Now I would like to click on an element on my homepage which I am not able to do bcos of some exceptions.
WebDriverWait wait = new WebDriverWait(d, TimeSpan.FromSeconds(30));
wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(d.FindElement(By.XPath("//span[@title='Start search']"))));
d.FindElement(By.XPath("//span[@title='Start search']")).Click();
}
异常 1:
然后我添加了Thread.Sleep(20000);在 Process.Start() 之后;这给了我一个新的异常。
例外情况 2:
我正在使用 FireFox v62 和最新的 firefox 驱动程序。
AutoIT v 3.3.14.5
你能帮我找到解决办法吗?
提前致谢。
使网络浏览器发出警报,以便网络浏览器在处理身份验证弹出窗口后进入焦点。
代码更改:
Process.Start(@"C:\Users\Documents\AutoIt Scripts\Authentication_FireFox.exe");
Thread.Sleep(30000);
((IJavaScriptExecutor)d).ExecuteScript("alert('Test')");
d.SwitchTo().Alert().Accept();
d.FindElement(By.XPath("//span[@title='Start search']")).Click(); // now this element is getting clicked.
我有一个网站,它通过身份验证 Window 弹出窗口提示输入用户名和密码。所以,我依靠 AutoIt 来处理弹出窗口并且它有效(输入用户名和密码)。
验证凭据后,我网站的主页将在 10-15 秒的时间间隔内打开。
这是我正在做的事情:
class Class1
{
FirefoxDriver d;
static void Main(string[] args)
{
d = new FirefoxDriver();
d.Manage().Window.Maximize();
d.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(60);
d.Url = "www.example.com";
Process.Start(@"C:\Users\Documents\AutoIt Scripts\Authentication_FireFox.exe");
//Now I would like to click on an element on my homepage which I am not able to do bcos of some exceptions.
WebDriverWait wait = new WebDriverWait(d, TimeSpan.FromSeconds(30));
wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(d.FindElement(By.XPath("//span[@title='Start search']"))));
d.FindElement(By.XPath("//span[@title='Start search']")).Click();
}
异常 1:
然后我添加了Thread.Sleep(20000);在 Process.Start() 之后;这给了我一个新的异常。
例外情况 2:
我正在使用 FireFox v62 和最新的 firefox 驱动程序。 AutoIT v 3.3.14.5
你能帮我找到解决办法吗? 提前致谢。
使网络浏览器发出警报,以便网络浏览器在处理身份验证弹出窗口后进入焦点。
代码更改:
Process.Start(@"C:\Users\Documents\AutoIt Scripts\Authentication_FireFox.exe");
Thread.Sleep(30000);
((IJavaScriptExecutor)d).ExecuteScript("alert('Test')");
d.SwitchTo().Alert().Accept();
d.FindElement(By.XPath("//span[@title='Start search']")).Click(); // now this element is getting clicked.