Verify Link open in a New tab

1,256 views
Skip to first unread message

Ashish b lal

unread,
Dec 17, 2014, 5:51:32 AM12/17/14
to seleniu...@googlegroups.com
I have to verify link open up in a new tab. Please help

--
Hope to hear soon from you.
    
Thanks & Regards,
Ashish.B.LAL

CH!NN@ K

unread,
Dec 17, 2014, 5:54:18 AM12/17/14
to seleniu...@googlegroups.com

---
Thanks & Regards,
Purushotham Karimbedu,
Druapl Developer and QA Engineer,
Website for Selenium : http://techlearn.in


--
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 post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAA9Wrszam1yYRsyYjpdyX2i4ci34QBW_nZGK-632QKww95O1VQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ashish b lal

unread,
Dec 17, 2014, 5:59:37 AM12/17/14
to seleniu...@googlegroups.com
Thanks,
There is list of sub menu  and when i click any sub menu then its open up in a new tab.
There is a change in URL, so i need to test that they are opening  Right URL


For more options, visit https://groups.google.com/d/optout.

http://thebuddhatree.com/

unread,
Dec 17, 2014, 6:17:46 AM12/17/14
to seleniu...@googlegroups.com
One solution could be read Page URL of opened tab/browser window & validate them.

Simon Berry-Byrne

unread,
Dec 18, 2014, 10:41:22 AM12/18/14
to seleniu...@googlegroups.com

 
public static void verifyIAmOnPageWithUrl(String pageUrl) {
       
short pollCounter = 6;
       
boolean displayed;
       
do {
            displayed
= getDriver().getCurrentUrl().contains(pageUrl);
           
ThreadUtils.sleep(1, "Sleeping to allow the page with url to load");
            pollCounter
--;
       
} while (!displayed && pollCounter >= 0);
       
//MakeTheAssertion(pageDisplayed, "I am on the page with the URL " + pageUrl);
   
}

This is one way of doing it. Does this solve your problem.

Rajeev Prabhakaran Nair

unread,
Dec 26, 2014, 2:11:57 AM12/26/14
to seleniu...@googlegroups.com
- Switch the browser tab using,sending shortcut commands.

For example if you send to

 driver.findElement(By.tagName("body")).sendKeys(Keys.CONTROL, "1");
it will switch to 1st tab.

- Then verify with getcurrenturl
- Add an assertion with expected(your expected url), actual result(current url result).


R

Andreas Tolfsen

unread,
Dec 29, 2014, 10:02:15 AM12/29/14
to seleniu...@googlegroups.com
On Fri, Dec 26, 2014 at 8:11 AM, Rajeev Prabhakaran Nair
<raje...@gmail.com> wrote:
> - Switch the browser tab using,sending shortcut commands.

A simpler approach if all you need to do is check if the click on a
link to open a new browser actually did that, is checking the number
of window handles.

before_wins = driver.get_window_handles()
opens_tab.click()
new WebDriverWait(driver).until(lambda d:
len(driver.get_window_handles()) > len(before_wins))
# new window is open
Reply all
Reply to author
Forward
0 new messages