我想閱讀Alert中的消息。從Alert中讀取消息,然後單擊OK
示例:如果警報顯示「錯誤的電子郵件地址」。如何閱讀?意思是我想把這個消息存儲在一個字符串中。
如何在Alert中點擊OK ...?
如何使用硒做到這一點?
我想閱讀Alert中的消息。從Alert中讀取消息,然後單擊OK
示例:如果警報顯示「錯誤的電子郵件地址」。如何閱讀?意思是我想把這個消息存儲在一個字符串中。
如何在Alert中點擊OK ...?
如何使用硒做到這一點?
我發現在Selenium RC中,如果您知道會有一個確認按鈕,那麼您需要需要將selenium.getConfirmation();
添加到您的代碼中。
下面是我用它(注意:我在Eclipse中使用Java)
selenium.click("//input[@id=\"accepted-emails\"]"); // Confirmation box after this line
if (selenium.isConfirmationPresent())
String confirmationString = selenium.getConfirmation(); // this line is needed
selenium.keyPressNative("10"); // to press the OK key
selenium.waitForPageToLoad("30000");
System.out.println(confirmationString); // this is not really needed, but used it to simply show the confirmation box message
希望這有助於!
我正在使用硒rc。 –
我更新了我的答案,包括Selenium RC。請檢查它是否有幫助。 –
這是一個更好的鏈接,我認爲(到當前主幹):http://selenium.googlecode.com/svn/trunk/docs/api/dotnet/html/M_Selenium_ISelenium_GetAlert.htm –