-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy path095 BrowserInteractions.py
53 lines (48 loc) · 1.7 KB
/
095 BrowserInteractions.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
'''
Created on May 30, 2018
@author: venkateshwara.d
'''
from selenium import webdriver
import os
class BrowserInteractions():
def test(self):
baseUrl = "https://letskodeit.teachable.com/pages/practice"
chrome_driver_path = os.path.abspath('..') + "\\Drivers\\chromedriver.exe"
driver=webdriver.Chrome(chrome_driver_path)
# Window Maximize
driver.maximize_window()
# Open the Url
driver.get(baseUrl)
# Get Title
title = driver.title
print("Title of the web page is: " + title)
# Get Current Url
currentUrl = driver.current_url
print("Current Url of the web page is: " + currentUrl)
# Browser Refresh
driver.refresh()
print("Browser Refreshed 1st time")
driver.get(driver.current_url)
print("Browser Refreshed 2nd time")
# Open another Url
driver.get("https://sso.teachable.com/secure/42299/users/sign_in?reset_purchase_session=1")
currentUrl = driver.current_url
print("Current Url of the web page is: " + currentUrl)
# Browser Back
driver.back()
print("Go one step back in browser history")
currentUrl = driver.current_url
print("Current Url of the web page is: " + currentUrl)
# Browser Forward
driver.forward()
print("Go one step forward in browser history")
currentUrl = driver.current_url
print("Current Url of the web page is: " + currentUrl)
# Get Page Source
pageSource = driver.page_source
print(pageSource.encode("utf-8"))
# Browser Close / Quit
# driver.close()
driver.quit()
ff = BrowserInteractions()
ff.test()