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. Attaching the code for reference.
My code is as below:-
w.get("https://www.hrmantra.com/LetsLead/18_Recruitment/SubmittResume.aspx?cn=LetsLead");
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=LetsLead");
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.