Friday, 15 February 2013

selenium - How to open multiple instances of Firefox using python? -



selenium - How to open multiple instances of Firefox using python? -

can please help me on how open multiple instances of firefox using selenium in python.

i wrote next code , open multiple instances want maintain references browser can access each browser specific tasks , should able quit browsers 1 time test done.

class loadtestcase(unittest.testcase): def setup(self): = 0 while (i < 2): self.driver = webdriver.firefox() self.driver.implicitly_wait(30) self.base_url = "http://example.com/" self.verificationerrors = [] self.accept_next_alert = true driver = self.driver url = "http://example.com/" driver.get(self.base_url + "/") = + 1

for 1 thing:

for in range(2): ...

is much neater , less error-prone than:

i = 0 while < 2: ... = + 1 # or 'i += 1'

but main problem each time through loop replace previous webdriver, losing access it:

self.driver = webdriver.firefox()

instead, consider list:

self.drivers = [] in range(2): self.drivers.append(webdriver.firefox()) ...

now retain access of them.

python selenium

No comments:

Post a Comment