Advertisement
Guest User

Untitled

a guest
May 31st, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. Thread.sleep(2000);
  2. // Store the current window handle
  3. String winHandleBefore = driver.getWindowHandle();
  4.  
  5. // Perform the click operation that opens new window
  6.  
  7. // Switch to new window opened
  8. for(String winHandle : driver.getWindowHandles()){
  9. driver.switchTo().window(winHandle);
  10. }
  11.  
  12. // Perform the actions on new window
  13. driver.findElement(By.xpath("ur xpath of that search box")).click();
  14. driver.findElement(By.xpath("ur xpath of that search box")).clear();
  15. driver.findElement(By.xpath("ur xpath of that search box")).sendKeys("ur text");
  16.  
  17.  
  18. // Close the new window, if that window no more required
  19. driver.close();
  20.  
  21. // Switch back to original browser (first window)
  22. driver.switchTo().window(winHandleBefore);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement