简体   繁体   English

Selenide - 如何处理 Chrome 中的 gmail 弹出窗口

[英]Selenide - How to handle gmail pop up in chrome

I am trying to switch to a Gmail login popup that appears on clicking a button on my chrome.我正在尝试切换到单击 chrome 上的按钮时出现的 Gmail 登录弹出窗口。 When I do a driver getWindowHandles(), it shows only one window - the parent.当我执行驱动程序 getWindowHandles() 时,它只显示一个窗口 - 父窗口。 Also I noticed in the taskbar that the popup that opens has a google/gmail icon instead of chrome browser icon which is why I am assuming that the Webdriver does not count it as a second open "chrome" window, but instead a different one altogether.我还注意到在任务栏中打开的弹出窗口有一个 google/gmail 图标而不是 chrome 浏览器图标,这就是为什么我假设 Webdriver 不将其视为第二个打开的“chrome”窗口,而是完全不同的.

So far I have tried everything on the driver methods到目前为止,我已经尝试了有关驱动程序方法的所有方法

driver.switchTo().window(1 or 0)

Any suggestions would be helpful!!任何的意见都将会有帮助!!

driver.switchTo().alert().anyMethod    

可以使用。

First of all, why are you using driver.首先,你为什么使用驱动程序。 with Selenide?与硒化物? Selenide has a static WebDriver call - getWebDriver() (if really needed) with the next import import static com.codeborne.selenide.WebDriverRunner.getWebDriver; Selenide 有一个静态的 WebDriver 调用 - getWebDriver()(如果真的需要的话)和下一个 import import static com.codeborne.selenide.WebDriverRunner.getWebDriver;

From your quesiton, it is not clear what you want - either its pop up that appears after clicking or you want to switch to another chrome tab window?从您的问题中,不清楚您想要什么 - 单击后出现的弹出窗口,或者您想切换到另一个 chrome 选项卡窗口?

If its a pop up alert, then the next code should help (to accept it for example):如果它是一个弹出警报,那么下一个代码应该会有所帮助(例如接受它):

getWebDriver().switchTo().alert().accept();

If you want to open a tab or focus on it:如果您想打开一个选项卡或专注于它:

switchTo().window(1);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM