0

I am working on a project and in this project there are two webpages I need to examine.I have to open these two webpages at the same time in different windows and examine them at the same time.

There must be two windows and there is a function that checks an element's status.But this function must be checking them at the same time.How can I solve this problem?
Thanks

2 Answers 2

2

You can open more than one browser at a time:

from selenium import webdriver

driver1 = webdriver.Firefox()
driver2 = webdriver.Firefox()

driver1.get(...)
driver2.get(...)

If you want two windows into the current driver session you can use a little javascipt to open a second window with a single driver:

driver.execute_script("$(window.open('http://www.example.com'))")
window1 = driver.window_handles[0]
window2 = driver.window_handles[1]

# test the first window
driver.switch_to_window(window1)
...

# test the second window
driver.switch_to_window(window2)
...
Sign up to request clarification or add additional context in comments.

Comments

0

I'm not sure about doing at at exactly the same time, but you could open one of the pages in a separate tab, then move between the two do your comparison.

driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL +"t");
ArrayList<String> tabs = new ArrayList<String> (driver.getWindowHandles());
driver.switchTo().window(tabs.get(0));
***get value to compare**** 
driver.switchTo().window(tabs.get(1));
driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL +"Keys.TAB");
***get second value and compare***

If not, perhaps look into using Selenium Grid to run two tests in parallel. I only spotted that you're working in Python after writing the answer, but im sure there's an equivalent.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.