简体   繁体   English

如何处理硒webdriver中具有空白ID的弹出窗口?

[英]How to handle pop up windows with blank id in selenium webdriver?

I want to automate the code for submit resume page in my application. 我想在我的应用程序中自动执行提交简历页面的代码。 The page consist of a section to add in the qualification details which further opens a window to add the same. 该页面包含一个用于添加资格详细信息的部分,该部分进一步打开一个窗口以添加相同的信息。 The problem is the window that is opening has blank id and on automating the same i get session expired message in it, which otherwise works fine when i access it through selenium ide or manually. 问题是正在打开的窗口具有空白ID,并且在自动执行该操作时,我在其中获得会话已过期消息,否则当我通过Selenium ide或手动访问它时,它将正常工作。 Attaching the code for reference. 附上代码以供参考。

My code is as below:- 我的代码如下:

w.get("https://www.hrmantra.com/LetsLead/18_Recruitment/SubmittResume.aspx?cn=L‌​etsLead");
String parentHandle = w.getWindowHandle();
w.findElement(By.xpath("//.//*[@id='lbAddQualification']")).click();
for (String winHandle: w.getWindowHandles()) {
    w.switchTo().window(winHandle);
    e = new Select(w.findElement(By.xpath("//.//*[@id='lstlist']")));
    e.selectByVisibleText("A Level DOEACC");
    w.findElement(By.xpath("//.//*[@id='Btnconadd']")).click();
    w.findElement(By.id("BtnAdd")).click();
}
w.switchTo().window(parentHandle);

After switch you need to right code outside the loop like this: 切换之后,您需要像这样在循环外部添加正确的代码:

static WebDriver driver=null;
public static void main(String[] args) {
    driver = new FirefoxDriver();
    driver.get("https://www.hrmantra.com/LetsLead/18_Recruitment/SubmittResume.aspx?cn=L‌​etsLead");
    driver.manage().window().maximize();
    driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);


    String mainwindow=driver.getWindowHandle();
    driver.findElement(By.xpath("//.//*[@id='lbAddQualification']")).click();

    for(String winHandle :driver.getWindowHandles()){
        driver.switchTo().window(winHandle);
    }
    // Here right your code which you want to perform on pop-up
    driver.close();
    // Back to main window
    driver.switchTo().window(mainwindow);

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

相关问题 如何处理弹出 windows Java Selenium? - How to handle pop up windows Java Selenium? 如何处理linkedIn授权使用Java在Selenium Webdriver中弹出? - How to Handle linkedIn authorization Pop up in selenium webdriver using Java? 如何使用Java处理Selenium WebDriver中的弹出窗口 - How to handle Pop-up in Selenium WebDriver using Java 如何在 selenium webdriver 中处理 Javascript 警报/弹出窗口 - How to handle Javascript Alert/pop up window in selenium webdriver 如何使用Selenium 2.0(WebDriver)处理Windows弹出窗口? - How to handle windows pop ups using selenium 2.0 (webdriver)? 无法在Selenium WebDriver中处理Ajax弹出窗口 - Unable to Handle Ajax Pop up in Selenium WebDriver 如何处理硒Webdriver中的简单HTML弹出窗口? - How to handle a pop up which is a simple HTML pop up in selenium webdriver? 无法在Selenium Webdriver中处理Sharepoint弹出页面 - Cannot handle Sharepoint pop-up page in Selenium Webdriver 如何使用Java处理Selenium Webdriver中下一个选项卡中弹出的所需身份验证? - How to handle authentication required pop up in next tab in selenium webdriver using java? 使用Selenium Webdriver下载excel时如何处理firefox中的下载弹出窗口 - How to handle download pop-up in firefox, while downloading excel using Selenium Webdriver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM