-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowserDemo.py
29 lines (26 loc) · 1.14 KB
/
browserDemo.py
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
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.firefox import GeckoDriverManager
from webdriver_manager.microsoft import EdgeChromiumDriverManager
# browser exposes an executable file
# Through selenium test we need to invoke the executable file which will then invoke actual browser
# driver = webdriver.Chrome(executable_path="D:\\Study materials and projects\\chromedriver_win32\\chromedriver.exe")
browserType = "chrome"
if "chrome" in browserType:
driver = webdriver.Chrome(ChromeDriverManager().install())
elif "firefox" in browserType:
driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
else:
driver = webdriver.Edge(EdgeChromiumDriverManager().install())
driver.get("https://demo.nopcommerce.com/")
driver.maximize_window()
print(driver.title)
print(driver.current_url)
assert driver.title == "nopCommerce demo store" # assert equals
assert "demo" in driver.title # is driver.title contains " demo " ? #true or false
driver.get("https://the-internet.herokuapp.com/")
driver.minimize_window()
driver.back()
driver.refresh()
driver.quit()
# driver.close()