0

My test case is about opening the child window by pressing the button located on main window and closing the child one and after that, i have to press another button which is in parent window but i can't do it because driver.switchTo().window(mainWindow) code doesn't work. I'm facing with "Timed out waiting for page to load." error and i don't know why. There's no problem like the page is not correctly uploaded.

Btw, I faced with the same problem using click() and sendKeys() methods before.

When i used the following type of button pressing method, rest of the code couldn't be executed and i was facing with same error included "time out"

driver.findElement(By.xpath("//input[@name='simcardICCI']")).click();

but when i prefered to use sendKeys , then the execution was going on.

driver.findElement(By.xpath("//input[@name='simcardICCI']")).sendKeys(Keys.ENTER);

Now, i'm experiencing the same issue while switching to main window but i couldn't handle it. What would be the reason?

String mainWindow = driver.getWindowHandle(); // taking the id of main window
    System.out.println(mainWindow);
    driver.findElement(By.xpath("//input[@name='simcardICCI']")).sendKeys(Keys.ENTER); // click the button and child window is opening
    Thread.sleep(1000);
    LineActivation.Windows(driver, mainWindow); // i'm directing the driver into child window by invoking the method which is in lineactivation class
    String simcardicci = null;
    driver.findElement(By.xpath("//input[@name='icci']")).clear();
    driver.findElement(By.xpath("//input[@name='icci']")).sendKeys(DBConnection2(simcardicci));
    driver.findElement(By.xpath("//input[@value='BUL']")).click();
    Thread.sleep(1000);
    driver.findElement(By.xpath("//input[@type='button']")).click();
    Thread.sleep(1000);
    driver.findElement(By.xpath("//input[@class='button']")).click(); // i'm pressing the button on child window and closing it
    Thread.sleep(3000);
    driver.switchTo().window(mainWindow); //this one is not working.

I'm getting "org.openqa.selenium.TimeoutException: Timed out waiting for page to load."

  • Remove thread.sleep and use Implicit/Explicit wait. You might be facing issue due to varying loading time due to network and fixed wait time due to thread.sleep. Check your LineActivation method. I can't understand the logic of passing mainwindow handle if you are switching to child window. – SRM21 Jun 3 at 6:02
  • It didn't work. – santino87 Jun 4 at 10:52
  • Did you try by passing child window handle to your lineactivation method? Can you please explain how does that method work? It would be better if you can share the modified code as well. – SRM21 Jun 4 at 11:01
  • mainWindow = driver.getWindowHandle(); Set<String> totalwindowsIds = driver.getWindowHandles(); int a=0; String[] myset = totalwindowsIds.toArray(new String[totalwindowsIds.size()]); if(myset[a].contains(mainWindow)){ driver.switchTo().window(myset[a+1]); } else{ driver.switchTo().window(myset[a]); } – santino87 Jun 4 at 12:10
  • i shared the code of windows method. Actually, it's working fine. I'm using it for other projects also but this problem's causing from another reason that i don't know. As mentioned before, i'm facing with same problem with click() and sendkeys() method also. If i use click method, click action is working but subsequently coming code is not executed but if i use sendkeys method, following codes are being executed so same type of issue is here also. last step on child window is clicking the button. i do it and child window is closing but i can't switch to main window. execution's getting stuck. – santino87 Jun 4 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.