Display results as :

Rechercher Advanced 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
//Update href attribute value
//Click link

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(""//img[@alt='imagetitle']/parent::a").target='myWindow'"); selenium.getEval("this.browserbot.getCurrentWindow().open('${path}', 'myWindow')")); selenium.clickLink("//img[@alt='imagetitle']/parent::a");
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.


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