tara srinivas
tara srinivas

Reputation: 9

Unable to print window ID out of the for-loop

I am trying to print my parent window id, but I am getting output as null. Unable to understand where I made a mistake.

first code screenshot

second code screenshot

Getting output as null when I try to print it out of the for-loop. Anyone, please help me with this?

Upvotes: -1

Views: 40

Answers (2)

Radek Sołdek
Radek Sołdek

Reputation: 53

Change declaration

String parentwin = driver.getWhindowHandle()

in if block to:

parentwin = driver.getWhindowHandle();

Upvotes: 0

Krishna Nagargoje
Krishna Nagargoje

Reputation: 11

you have used ,parentwin' as a local variable in first 'if' block. It's scope will be limited to the 'if' block. Hence getting null.

solution- remove declaration of parentwin from if block.

Upvotes: 1

Related Questions