Selenium WebDriver (selenium-dotnet-2.25.1) + IEDriverServer.exe (IEDriverServer_Win32_2.25.2) を使用してデータを再投稿した後、モーダル アラート ウィンドウを渡そうとしています。
これは私のテスト C# コードです。
static void Main(string[] args)
{
IWebDriver driver = new OpenQA.Selenium.IE.InternetExplorerDriver();
// Navigating to gmail.com and submitting wrong data
driver.Navigate().GoToUrl("gmail.com");
driver.FindElement(By.Id("Email")).SendKeys("testuser");
driver.FindElement(By.Id("signIn")).Click();
Thread.Sleep(8000);
// making the data re-post by F5
driver.Navigate().Refresh();
// Handling the aller and accepting it
IAlert alert = driver.SwitchTo().Alert();
Console.WriteLine(alert.Text);
alert.Accept();
}
これはプログラム出力です:
Started InternetExplorerDriver server (32-bit)
2.25.2.0
Listening on port 2783
To display the webpage again, Internet Explorer needs to
resend the information you've previously submitted.
If you were making a purchase, you should click Cancel to
avoid a duplicate transaction. Otherwise, click Retry to display
the webpage again.
Press any key to continue . . .
その結果、アラート ウィンドウはデータを再ポストせずに消え、IE は「ページの有効期限が切れています」と表示します。
ご意見をお聞かせください。