简体   繁体   English

如何获取硒webdriver中使用firepath阻止主屏幕的弹出屏幕的对象?

[英]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.

相关问题 如何使用 Selenium WebDriver 捕获弹出窗口的屏幕? - How to capture screen of pop up window using Selenium WebDriver? 使用 Selenium Webdriver 的登录弹出窗口 - Login Pop-Up Using Selenium Webdriver 如何使用Java处理Selenium WebDriver中的弹出窗口 - How to handle Pop-up in Selenium WebDriver using Java 无法使用Java在Selenium Webdriver中的弹出窗口中单击按钮 - Unable to click on a button in Pop-up in Selenium webdriver using java 如何使用WebDriver(Selenium JAVA)处理Telerik弹出窗口 - How to deal with Telerik pop-up window with WebDriver (selenium JAVA) 如何使用JAVA在Selenium Webdriver的Internet Explorer中处理服务器身份验证弹出窗口? - How can i handle Server authentication pop-up in Internet Explorer in Selenium Webdriver using JAVA? 如何使用带有Java的Selenium Webdriver处理允许弹出的Firefox插件 - How do I handle allow pop-up of plug-in for firefox using Selenium Webdriver with Java 使用Selenium Webdriver下载excel时如何处理firefox中的下载弹出窗口 - How to handle download pop-up in firefox, while downloading excel using Selenium Webdriver 如何在github中使用Selenium Web Driver管理弹出窗口 - How to manage pop-up using Selenium Web Driver in github 如何使用 selenium/java 切换到新的弹出窗口 window - How to switch to a new pop-up window using selenium/java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM