I'm able to switch to a different window using codeception action whereas 'switchToWindow()' fails for me to return to default/parent window.Please help me on this.
Please add more information, especially the error message.
It throws noSuchWindowException.
The scenario is , i'm switching to a window and performing few operation and closing the window.After that i want to return back to default window...I'm using $I->switchToWindow();
But it's' failing.Please suggest.
I assume you work with the WebDriver module?
Have you tried
<?php $I->executeInSelenium(function (\Webdriver $webdriver) { $handles=$webdriver->getWindowHandles(); $last_window = end($handles); $webdriver->switchTo()->window($last_window); }); ?>
from the docs?
Yes i have used this.But what i want is, how can i switch back to my default window ??
So how would be able to achieve the 3rd point mentioned above ??
Solved Now.Thanks Everyone.
What was the solution?
Before siwtching to new window, i stored the window handle of current window like thi s: -
$curr_window=$webdriver->getWindowHandle();
And at last used this , $I->switchToWindow($curr_window);
I'm new of codeception, it's trouble to declare $webdriver in my code. Could you share complete code to switch window as you mention above. Thank so much.
@ksubudhi Can you please share the complete code of the following steps-* First i have to switch to window* Do some operation* Switch back to default window