-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
95 lines (78 loc) · 3.26 KB
/
main.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import time
import unittest
import os
from selenium import webdriver
from selenium.webdriver.common.by import By
username = os.getenv("LT_USERNAME") # Replace the username
access_key = os.getenv("LT_ACCESS_KEY") # Replace the access key
build_name = os.getenv("LT_BUILD_NAME")
# username = "rupamd"
# access_key = "g8bSPewKA2UPOBkcfGMcv1Vmc8N9CM11gIDUUyL9q9a8OpxUwc"
class FirstSampleTest(unittest.TestCase):
def setUp(self):
options = webdriver.ChromeOptions();
options.browser_version = "117.0"
# options.platform_name = "macOS Sonoma";
lt_options = {};
lt_options["platformName"]="macOS Sonoma";
lt_options["username"] = "rupamd";
lt_options["accessKey"] = "g8bSPewKA2UPOBkcfGMcv1Vmc8N9CM11gIDUUyL9q9a8OpxUwc";
lt_options["project"] = "Untitled";
lt_options["w3c"] = True;
lt_options["plugin"] = "python-python";
lt_options["build"] = build_name;
lt_options["name"] = "rupamd";
lt_options["tunnel"] = 'true';
lt_options["tunnelName"] = os.getenv("LT_TUNNEL_NAME");
# lt_options["tunnelName"] = "rupamd";
options.set_capability('LT:Options', lt_options);
self.driver = webdriver.Remote(
command_executor="http://{}:{}@hub.lambdatest.com/wd/hub".format(
username, access_key),
options=options)
# tearDown runs after each test case
def tearDown(self):
self.driver.quit()
# """ You can write the test cases here """
def test_demo_site(self):
# try:
driver = self.driver
driver.implicitly_wait(10)
driver.set_page_load_timeout(30)
driver.set_window_size(1920, 1080)
# driver.get("file:///C:/Users/")
# driver.implicitly_wait(20)
driver.get("http://localhost:8000/")
driver.implicitly_wait(5)
# Url
print('Loading URL')
driver.get("https://stage-lambda-devops-use-only.lambdatestinternal.com/To-do-app/index.html")
# Let's click on a element
driver.find_element(By.NAME, "li1").click()
location = driver.find_element(By.NAME, "li2")
location.click()
print("Clicked on the second element")
time.sleep(60)
#Take Smart UI screenshot
#driver.execute_script("smartui.takeScreenshot")
# Let's add a checkbox
driver.find_element(By.ID, "sampletodotext").send_keys("LambdaTest")
add_button = driver.find_element(By.ID, "addbutton")
add_button.click()
print("Added LambdaTest checkbox")
# print the heading
search = driver.find_element(By.CSS_SELECTOR, ".container h2")
assert search.is_displayed(), "heading is not displayed"
print(search.text)
search.click()
driver.implicitly_wait(80)
# Let's download the invoice
heading = driver.find_element(By.CSS_SELECTOR, ".container h2")
if heading.is_displayed():
heading.click()
driver.execute_script("lambda-status=passed")
print("Tests are run successfully!")
else:
driver.execute_script("lambda-status=failed")
if __name__ == "__main__":
unittest.main()