How can I close a specific window using Selenium WebDriver with Java? -


I use Selenium WebDriver I open the first page and open another page - take a few actions and return to the first page Go before I want to close the second page, I driver.close (); I use the command , but it closes the first page in place of the other. How can I create Selenium to close a specific window?

Part of the code

  before the string handle = driver.Janavandhandle (); . Click on Driver.findElement (By.xpath ("...")) (); (String blocking: driver.getWindowHandles ()) {driver.switchTo (). Window (Dakhandi); } Driver.findElement (By.linkText ("001")). Click (); Driver.close ();  

  string base = driver .getWindowHandle (); Set & lt; String & gt; Set = driver.getWindowHandles (); Set.remove (base); Set up Size () == 1; Driver.changeTo () Window (set.toArray (new string [0])); Driver.close (); Driver.switchTo () window (base)  

This works for me ...


Comments

Popular posts from this blog

java - NullPointerException for a 2d Array -

python - Assemble mpeg file unable to play in mediaplayer -

c# - NameSpace Manager or XsltContent to parse aspx page -