How to access newly opened page in same tab using selenium webdriver?

162 views
Skip to first unread message

Bilal Shahzad

unread,
Sep 12, 2019, 9:12:04 AM9/12/19
to Selenium Users

I am unable to access the newly opened page after submitting a form in same tab (not in new tab). I am a newbie in selenium driver, please help me.

In-fact, I accessed first page and filled form successfully, and then I clicked a submit button and proceed to next page, opened in same tab. But then I failed to access that newly opened page.

I also use 10 sec explicit wait to manage form submission and new page opening time but doesn't working. I didn't use WindowHandles() because I am not comfortable to use that. Will Windowhandles() work ?

Only one way I am able to access new page by using separately navigate().to() method after clicking submit button. But is this good approach to get control at new page rather than automating control to new page by some other way ?

I used following explicit wait and then accessed a button at newly page, but doesn't working:

WebDriverWait WaitVar = new WebDriverWait (driver, 10);

WaitVar.until(ExpectedConditions.visibilityOfElementLocated(By.id("BTNCustomQuestionFinalStep")));

driver.findElement(By.id("BTNCustomQuestionFinalStep")).click();


Without using explicit wait I got following error:

no such element: Unable to locate element


After using explicit wait I got following error:

Expected condition failed: waiting for visibility of element located by By.id: BTNCustomQuestionFinalStep (tried for 10 second(s) with 500 milliseconds interval)

chetan baraskar

unread,
Sep 12, 2019, 10:02:01 AM9/12/19
to seleniu...@googlegroups.com
Hi,

Just try to increase wait by from 10 to 20
also, check for condition wait.until(ExpectedConditions.elementToBeClickable(by locator));

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/60be9e9f-80d0-4b24-bb2e-ce0e028bf0b5%40googlegroups.com.


--
Have a Nice Day
Chetan

Bilal Shahzad

unread,
Sep 13, 2019, 8:35:22 AM9/13/19
to Selenium Users
Hi Chetan,

As you said I also increased wait time from 10 to 20. After that I also tried ExpectedConditions.elementToBeClickable but nothing working.
Help me please.
To unsubscribe from this group and stop receiving emails from it, send an email to seleniu...@googlegroups.com.

Mukesh M

unread,
Sep 13, 2019, 10:28:04 AM9/13/19
to seleniu...@googlegroups.com

Hi Bilal,

 

Check is the element is located inside an iframe.

 

 

அனுப்புநர்: Bilal Shahzad
அனுப்பியது: 13 September 2019 18:05
பெறுநர்: Selenium Users
பொருள்: Re: [selenium-users] How to access newly opened page in same tabusing selenium webdriver?

To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c2f9253d-f43e-4c75-9861-851e12ddbad8%40googlegroups.com.

 

Bilal Shahzad

unread,
Sep 16, 2019, 12:20:18 AM9/16/19
to Selenium Users
Hi Mukesh M,


No, there is no element at my page. So the element is not located inside any iframe.
By the way, I used thread.sleep(3000) and it worked. But I also read that using thread.sleep is not recommended at all.
Now please tell me that either I use thread.sleep or can you please help tell me any other way ?

By the way, Thanks for your reply.

Shivam Singh

unread,
Sep 16, 2019, 12:29:54 AM9/16/19
to seleniu...@googlegroups.com
I was suspecting the same, it seems the webelement is inside the iframe.

Bilal Shahzad

unread,
Sep 16, 2019, 12:35:28 AM9/16/19
to Selenium Users
No @Shivam i double checked now, element is not in iframe.
After that now I used thread.sleep(300) and it worked.
But please tell me that is thread.sleep is good approach to get wait on page. I read that using thread.sleep is not recommended at all

Thanks for your reply.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seleniu...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages