forked from LambdaTest/pyunit-selenium-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle_test.py
More file actions
46 lines (35 loc) · 1.59 KB
/
single_test.py
File metadata and controls
46 lines (35 loc) · 1.59 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
38
39
40
41
42
43
44
45
46
import os
import unittest
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
username = os.environ.get("LT_USERNAME")
access_key = os.environ.get("LT_ACCESS_KEY")
class FirstSampleTest(unittest.TestCase):
def setUp(self):
lt_options = {
"build": "PyunitTest sample build", # Change your build name here
"name": "Py-unittest", # Change your test name here
"platformName": "Windows 10", # Change your OS version here
"browserName": "chrome", # Change your browser here
"browserVersion": "latest", # Change your browser version here
}
options = Options()
options.set_capability("LT:Options", lt_options)
self.driver = webdriver.Remote(
command_executor=f"https://{username}:{access_key}@hub.lambdatest.com/wd/hub",
options=options
)
def tearDown(self):
self.driver.quit()
def test_unit_user_should_able_to_add_item(self):
driver = self.driver
driver.get("https://lambdatest.github.io/sample-todo-app/")
driver.find_element("name", "li1").click()
driver.find_element("name", "li2").click()
driver.find_element("id", "sampletodotext").send_keys("Yey, Let's add it to list")
driver.find_element("id", "addbutton").click()
added_item = driver.find_element("xpath", "(//span[contains(@class,'text-base')])[6]").text
print("Added item:", added_item)
self.assertIn("Yey", added_item)
if __name__ == "__main__":
unittest.main()