[英]Windows handling in Selenium webdriver using java
I have a scenario as below 我有以下情况
1. Login to the application
2. click on a button (say Buy)
3. This will take me to a new window opened with a new URL automatically
4. Perform actions in the new window
5. Quit
Kindly please provide the exact code to work on this. 请提供确切的代码以解决此问题。 I tried with the available code that exists in the website which didnt work for me 我尝试了网站上存在的可用代码,但对我无效
You can try on following pattern:- 您可以尝试以下模式:
Webdriver driver = new ChromeDriver();
driver.get("URL of application");
driver.findElement(By.id("username").sendKeys("user1");
driver.findElement(By.id("password").sendKeys("pass1");
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
driver.findElement(By.xPath("xpath of button").click();
//now you can switch to pop-up and accordingly accept or dismiss it //现在您可以切换到弹出式窗口并相应地接受或关闭它
driver.switchTo().alert().accept();
driver.quit();
In case you provide the SO community the URL of application then only complete code can be provided. 如果您向SO社区提供应用程序的URL,则只能提供完整的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.