我是Slenium的新人。
I am trying to handle the pop-up Form.
我正在尝试处理弹出窗体。
When I click in New Button the pop-up form like this will open.
当我点击New Button时,会打开这样的弹出窗体。
I try the handle this by alert(), pop up handling and also by Child Browser Handling. But didn't get the solution. Please suggest some solution for this issue
我通过alert(),弹出处理以及子浏览器处理来尝试处理。但没有得到解决方案。请为此问题提出一些解决方案
1 个解决方案
#1
1
If it's an <iframe> element then you need to switch WebDriver to this frame in order to work with it. Here's an example of how you can do this:
如果它是
By locIframe = By.xpath("//iframe[@name='popup']");
driver.switchTo().frame(driver.findElement(locIframe));
// driver is an instance of RemoteWebDriver
The Xpath locator is just an example: you need to write your own here. Also you can use any other locator to find that <iframe> element in the page source.
Xpath定位器只是一个例子:你需要在这里编写自己的。您还可以使用任何其他定位器在页面源中查找
After switching to iframe element WebDriver will see it's page source and will be able to work with it.
切换到iframe元素后,WebDriver将看到它的页面源,并且能够使用它。
#1
1
If it's an <iframe> element then you need to switch WebDriver to this frame in order to work with it. Here's an example of how you can do this:
如果它是
By locIframe = By.xpath("//iframe[@name='popup']");
driver.switchTo().frame(driver.findElement(locIframe));
// driver is an instance of RemoteWebDriver
The Xpath locator is just an example: you need to write your own here. Also you can use any other locator to find that <iframe> element in the page source.
Xpath定位器只是一个例子:你需要在这里编写自己的。您还可以使用任何其他定位器在页面源中查找
After switching to iframe element WebDriver will see it's page source and will be able to work with it.
切换到iframe元素后,WebDriver将看到它的页面源,并且能够使用它。