Skip to content

Commit cdc3c5b

Browse files
authored
Merge pull request #2 from likith-lt/master
demo script updated
2 parents 009e7c3 + 7d3f0f3 commit cdc3c5b

File tree

1 file changed

+59
-31
lines changed

1 file changed

+59
-31
lines changed

lambdatest.py

Lines changed: 59 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,88 @@
1+
12
import unittest
2-
import sys
3+
import time
4+
import os
35
from selenium import webdriver
6+
from selenium.webdriver.common.by import By
7+
8+
username = os.getenv("LT_USERNAME") # Replace the username
9+
access_key = os.getenv("LT_ACCESS_KEY") # Replace the access key
410

5-
username = "Your Username" # Replace the username
6-
access_key = "Your Access Key" # Replace the access key
711

812
class FirstSampleTest(unittest.TestCase):
913
# Generate capabilites from here: https://www.lambdatest.com/capabilities-generator/
10-
# setUp runs before each test case and
14+
# setUp runs before each test case and
1115
def setUp(self):
1216
desired_caps = {
13-
"build": 'PyunitTest sample build', # Change your build name here
14-
"name": 'Py-unittest', # Change your test name here
15-
"browserName": 'Chrome',
16-
"version": '92.0',
17-
"platform": 'Windows 10',
18-
"resolution": '1024x768',
19-
"console": 'true', # Enable or disable console logs
20-
"network":'true' # Enable or disable network logs
17+
'LT:Options': {
18+
"build": "Python Demo", # Change your build name here
19+
"name": "Python Demo Test", # Change your test name here
20+
"platformName": "Windows 11",
21+
"selenium_version": "4.0.0",
22+
"console": 'true', # Enable or disable console logs
23+
"network": 'true' # Enable or disable network logs
24+
},
25+
"browserName": "Chrome",
26+
"browserVersion": "98.0",
2127
}
28+
2229
self.driver = webdriver.Remote(
23-
command_executor="https://{}:{}@hub.lambdatest.com/wd/hub".format(username, access_key),
24-
desired_capabilities= desired_caps)
30+
command_executor="https://{}:{}@hub.lambdatest.com/wd/hub".format(
31+
username, access_key),
32+
desired_capabilities=desired_caps)
2533

2634

2735
# tearDown runs after each test case
36+
37+
2838
def tearDown(self):
2939
self.driver.quit()
3040

3141
# """ You can write the test cases here """
32-
def test_unit_user_should_able_to_add_item(self):
42+
def test_demo_site(self):
43+
3344
# try:
3445
driver = self.driver
3546

3647
# Url
37-
driver.get("https://lambdatest.github.io/sample-todo-app/")
48+
print('Loading URL')
49+
driver.get("https://stage-demo.lambdatest.com/")
50+
51+
# Let's select the location
52+
driver.find_element(By.ID, "headlessui-listbox-button-1").click()
53+
location = driver.find_element(By.ID, "Bali")
54+
location.click()
55+
print("Location is selected as Bali.")
3856

39-
# Click on check box
40-
check_box_one = driver.find_element_by_name("li1")
41-
check_box_one.click()
57+
# Let's select the number of guests
58+
driver.find_element(By.ID, "headlessui-listbox-button-5").click()
59+
guests = driver.find_element(By.ID, "2")
60+
guests.click()
61+
print("Number of guests are selected.")
4262

43-
# Click on check box
44-
check_box_two = driver.find_element_by_name("li2")
45-
check_box_two.click()
63+
# Searching for the results
64+
search = driver.find_element(By.XPATH, "//*[@id='search']")
65+
search.click()
66+
driver.implicitly_wait(3)
4667

47-
# Enter item in textfield
48-
textfield = driver.find_element_by_id("sampletodotext")
49-
textfield.send_keys("Yey, Let's add it to list")
68+
# Let's select one of the hotels for booking
69+
reserve = driver.find_element(By.ID, "reserve-now")
70+
reserve.click()
71+
driver.implicitly_wait(3)
72+
proceed = driver.find_element(By.ID, "proceed")
73+
proceed.click()
74+
driver.implicitly_wait(3)
75+
print("Booking is confirmed.")
5076

51-
# Click on add button
52-
add_button = driver.find_element_by_id("addbutton")
53-
add_button.click()
77+
# Let's download the invoice
78+
download = driver.find_element(By.ID, "invoice")
79+
if (download.is_displayed()):
80+
download.click()
81+
driver.execute_script("lambda-status=passed")
82+
print("Tests are run successfully!")
83+
else:
84+
driver.execute_script("lambda-status=failed")
5485

55-
# Verified added item
56-
added_item = driver.find_element_by_xpath("//span[@class='done-false']").text
57-
print (added_item)
5886

5987
if __name__ == "__main__":
6088
unittest.main()

0 commit comments

Comments
 (0)