[英]How to get object of Pop-up screen that blocks the main screen using firepath in selenium webdriver?
I am writing an automation script in Java in selenium webdriver. 我正在用Java在Selenium Webdriver中编写自动化脚本。 When I try to logoff my main window screen I am getting a pop-up window that does not allow me to go to the main screen unless I click some option "Leave page" or "Stay on page" .
当我尝试注销主窗口屏幕时,出现一个弹出窗口,除非单击某些选项“离开页面”或“停留在页面上”,否则将不允许我进入主屏幕。 Can I get the script to close this screen and logoff the main application.Firepath does not work for this as well.
我可以让脚本关闭此屏幕并注销主应用程序吗。Firepath对此也不起作用。 I am a beginner trying to learn automation.Thanks.
我是一个尝试学习自动化的初学者。谢谢。
Adding some of your code to the question would be useful... 将一些代码添加到问题中将非常有用...
Here is a wild guess, assuming that you have a WebDriver driver
instance: 假设您有一个
WebDriver driver
实例,这是一个疯狂的猜测:
driver.switchTo().alert().accept(); // Leave Page
driver.switchTo().alert().dismiss(); // Stay on page
Try these first: 首先尝试这些:
driver.switchTo().alert().accept(); // to leave page
or 要么
driver.switchTo().alert().dismiss(); // to accept page
if doesn't work, then you can use Robot class to press Enter or any Key like - 如果不起作用,则可以使用Robot类按Enter或任何键,例如-
Robot robot = new Robot();
robot.setAutoDelay(3000);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
Only thing you've to notice - which button the default cursor or which one is highlighted, Robot will perform action on the highlighted object only, from there you can press tab to go anywhere else. 您唯一需要注意的是-默认光标是哪个按钮,或者哪个光标被突出显示,Robot将仅对突出显示的对象执行操作,从那里您可以按Tab键转到其他位置。 Hope this helps.
希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.