Webdriver | Work With Multiple Browsers | Driver Parking

Driver parking is a concept that allows working with multiple browsers without loosing the instance of any. It allows the storage of additional 5 drivers which can be switched with the host drivers by using inbuilt methods. The below test demonstrates the use of two additional drivers.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
''Park upto 5 instances of driver''

'Initialize the driver
 Call wd.InitializeFireFoxDriver("C:\Users\jaska\Desktop\selenium")
 
'Navigate to the desired URL
 Call wd.NavigateToUrl("https://www.google.com/")
 
'Park the current object instance in the reserved space - so that a new driver object can be created without loosing the old one
'FF driver - Parking Space 1
 Call wd.ParkDriver1()
 
'Initialize IE Driver
 Call wd.InitializeInternetExplorerDriver("C:\Users\jaska\Desktop\selenium")
 
'Navigate to the desired URL
 Call wd.NavigateToUrl("https://www.google.com/")
 
'Park the current object instance in the reserved space - so that a new driver object can be created without loosing the old one
'IE driver - Parking Space 2
 Call wd.ParkDriver2()
 
'Initialize Chrome Driver
 Call wd.InitializeChromeDriver("C:\Users\jaska\Desktop\selenium")
 
'Navigate to the desired URL
 Call wd.NavigateToUrl("https://www.google.com/")
 
'Type in Chrome
 Call wd.SendKeys("name::q","This is Chrome")
 
'Switch Back to Internet Explorer
 Call wd.UnParkDriver2()
 
'Type in IE
 Call wd.SendKeys("name::q","This is IE")
 
'Switch Back to FireFox
 Call wd.UnParkDriver1()
 
'Type in FireFOX
 Call wd.SendKeys("name::q","This is Firefox")

Add a Comment

Your email address will not be published. Required fields are marked *