Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

» Selenium IDE Verify different Maps (Hybridview, Mapview etc.)
Fri Nov 25, 2016 9:56 pm by DJ87

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Problem with anchor tag target attr value _blank

View previous topic View next topic Go down

Problem with anchor tag target attr value _blank

Post by srividya on Mon Apr 18, 2011 4:50 pm

Using Selenium(Java client) , I want to Click a link on a page, which will open a new browser window and need to test some content in newly opened browser window.

My problem is that i cant able to target that new window and check to see if that page loaded.

I tried with the following approaches,

First Approach:

//Retrieve href attribute value of anchor tag
String path=selenium.getAttribute("//img[@alt='myimage']/parent::a@href");
//Remove target attribute of anchor tag
selenium.getEval("this.page().findElement("//img[@alt='imagetitle']/parent::a").removeAttribute('target')");
//Update href attribute value
selenium.getEval("this.page().findElement("//img[@alt='imagetitle']/parent::a").href=”window.open('${path}','myWindow’)"));
//Click link
selenium.clickLink("//img[@alt='imagetitle']/parent::a");
Thread.sleep(10000);

Problem with this approach is that the new window link is getting opened as a sub frame in the main window,but i want it to be opened in a new window.How can i do this?

Second Approach:

//Update target attribute
selenium.getEval("this.page().findElement("//img[@alt='imagetitle']/parent::a").target='myWindow'"); selenium.getEval("this.browserbot.getCurrentWindow().open('${path}', 'myWindow')")); selenium.clickLink("//img[@alt='imagetitle']/parent::a");
Thread.sleep(10000);
ClsWebControls.selectWindow("myWindow"); ClsWebControls.windowFocus();

Problem with this approach is that a new browser window is getting opened, but i cant able to target that new window using selectWindow command.Following exception is getting raised:
com.thoughtworks.selenium.SeleniumException: ERROR: Could not find window with title "myWindow"

Does selenium support anchor tag with target '_blank'?
Also please suggest me solutions for the problems mentioned in the above two approaches.

srividya

Posts : 1
Join date : 2011-04-18

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum