Clicking a LinkValue in a Child Window and Passing Value to parent window.

I have a web application where i have a image, when i click on that image a new pop up window opens, which shows list of values. There is a Javascript executed when i click on any value.When i click on any value that value is passed to the parent window in a text field.
How can i achieve this through Selenium. Your help will be appreciated. Below the HTML of the link .

<a href=”javascript:passBack(v[1], v2[1]);>583 – WALNUT DISTRIBUTION CENTER</a>

rehanshahid Train Asked on November 3, 2015 in Selenium WebDriver.
Add Comment
4 Answer(s)

You need to capture the window handles using the below syntax –

String parentWindow = driver.getWindowHandle();
Set<String> handles = driver.getWindowHandles();
for(String windowHandle : handles)
// Perform the click operation in child window

// …

// Close the child window in case if you are done with the operation or you can just leave it in case if there  are any other operations pending so that you can switch to child window


//Switch to parent window


//verify the text here..




SD Train Answered on November 4, 2015.
Add Comment


I am able to switch to child window but not able to click on the javascript link in child window.


There is a passback javascript which is executed when i click on the link in child window. Below is the HTML of link.

<a href=”javascript:passBack(v[1], v2[1]);>583 – WALNUT DISTRIBUTION CENTER</a>

is there any way i can click on that link through selenium.

rehanshahid Train Answered on November 5, 2015.
Add Comment


Did you try the logic that we have given to you in  the other similar question that you had posted?

Virender Singh Professor Answered on November 5, 2015.
Add Comment


I tried, but i did not work, I will really appreciate if you can help me find a solution to this.

I can share my screen to you, and show you what i am trying to do. This way you can better understand the problem.

rehanshahid Train Answered on November 5, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.