-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTypes_of_Loacators.py
44 lines (26 loc) · 1.53 KB
/
Types_of_Loacators.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
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
# Creating an object for Options
chrome_options = Options()
# This will resolve the error if chrome browser is closing automatically after opening.
chrome_options.add_experimental_option("detach", True)
# This will create an object for Service where we need to provide the chromedriver.exe path
sev_obj = Service("E:\Drivers\chromedriver_win32\chromedriver.exe")
# This will open google chrome
driver = webdriver.Chrome(service=sev_obj,options=chrome_options)
# This will maximize browser window
driver.maximize_window()
# This will open facebook website login page.
driver.get("https://www.facebook.com/")
# This will send "helloall@gmail.com" to username box in login page.
# This is an example to find an element by using ID locator.
# driver.find_element(By.ID,"email").send_keys("helloall@gmail.com")
# This will send "helloall@gmail.com" to username box in login page.
# This is an example to find an element by using NAME locator.
# driver.find_element(By.NAME,"email").send_keys("helloall@gmail.com")
# This will click on login in button. This is an example to find an element by using CLASS NAME locator.
# driver.find_element(By.CLASS_NAME,"_6ltg").click()
# This will click on login in button. This is an example to find an element by using TAG NAME locator.
driver.find_element(By.TAG_NAME,"button").click()