-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdynamicXPath.py
More file actions
37 lines (27 loc) · 1.13 KB
/
dynamicXPath.py
File metadata and controls
37 lines (27 loc) · 1.13 KB
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
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
class DynamicXPathFormat():
def test(self):
baseUrl = "https://www.letskodeit.com/home"
driver = webdriver.Firefox()
driver.maximize_window()
driver.implicitly_wait(5)
driver.get(baseUrl)
# Login -> Click on "SIGN IN"
driver.find_element(By.LINK_TEXT, "SIGN IN").click()
email = driver.find_element(By.ID, "email")
email.send_keys("test@email.com")
password = driver.find_element(By.ID, "login-password")
password.send_keys("abcabc")
driver.find_element(By.ID, "login").click()
# Search for courses
searchBox = driver.find_element(By.ID, "search-courses")
searchBox.send_keys("JavaScript")
# Select Course using dynamic XPath
_course = "//div[contains(@class,'course-listing-title') and contains(text(),'{0}')]"
_courseLocator = _course.format("JavaScript for beginners")
courseElement = driver.find_element(By.XPATH, _courseLocator)
courseElement.click()
ff = DynamicXPathFormat()
ff.test()