-
Notifications
You must be signed in to change notification settings - Fork 12
/
single_test.py
59 lines (46 loc) · 1.9 KB
/
single_test.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
54
55
56
57
58
59
import os
import unittest
import sys
from selenium import webdriver
username = os.environ.get("LT_USERNAME")
access_key = os.environ.get("LT_ACCESS_KEY")
class FirstSampleTest(unittest.TestCase):
# Generate capabilites from here: https://www.lambdatest.com/capabilities-generator/
# setUp runs before each test case and
def setUp(self):
desired_caps = {
"build": 'PyunitTest sample build', # Change your build name here
"name": 'Py-unittest', # Change your test name here
"platform": 'Windows 10', # Change your OS version here
"browserName": 'chrome', # Change your browser here
"version": 'latest' # Change your browser version here
}
self.driver = webdriver.Remote(
command_executor="https://{}:{}@hub.lambdatest.com/wd/hub".format(username, access_key),
desired_capabilities=desired_caps)
# tearDown runs after each test case
def tearDown(self):
self.driver.quit()
# """ You can write the test cases here """
def test_unit_user_should_able_to_add_item(self):
# try:
driver = self.driver
# Url
driver.get("https://lambdatest.github.io/sample-todo-app/")
# Click on check box
check_box_one = driver.find_element_by_name("li1")
check_box_one.click()
# Click on check box
check_box_two = driver.find_element_by_name("li2")
check_box_two.click()
# Enter item in textfield
textfield = driver.find_element_by_id("sampletodotext")
textfield.send_keys("Yey, Let's add it to list")
# Click on add button
add_button = driver.find_element_by_id("addbutton")
add_button.click()
# Verified added item
added_item = driver.find_element_by_xpath("//span[@class='done-false']").text
print(added_item)
if __name__ == "__main__":
unittest.main()