Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 59 additions & 31 deletions lambdatest.py
Original file line number Diff line number Diff line change
@@ -1,60 +1,88 @@

import unittest
import sys
import time
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

username = "Your Username" # Replace the username
access_key = "Your Access Key" # Replace the access key

class FirstSampleTest(unittest.TestCase):
# Generate capabilites from here: https://www.lambdatest.com/capabilities-generator/
# setUp runs before each test case and
# 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
"browserName": 'Chrome',
"version": '92.0',
"platform": 'Windows 10',
"resolution": '1024x768',
"console": 'true', # Enable or disable console logs
"network":'true' # Enable or disable network logs
'LT:Options': {
"build": "Python Demo", # Change your build name here
"name": "Python Demo Test", # Change your test name here
"platformName": "Windows 11",
"selenium_version": "4.0.0",
"console": 'true', # Enable or disable console logs
"network": 'true' # Enable or disable network logs
},
"browserName": "Chrome",
"browserVersion": "98.0",
}

self.driver = webdriver.Remote(
command_executor="https://{}:{}@hub.lambdatest.com/wd/hub".format(username, access_key),
desired_capabilities= desired_caps)
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):
def test_demo_site(self):

# try:
driver = self.driver

# Url
driver.get("https://lambdatest.github.io/sample-todo-app/")
print('Loading URL')
driver.get("https://stage-demo.lambdatest.com/")

# Let's select the location
driver.find_element(By.ID, "headlessui-listbox-button-1").click()
location = driver.find_element(By.ID, "Bali")
location.click()
print("Location is selected as Bali.")

# Click on check box
check_box_one = driver.find_element_by_name("li1")
check_box_one.click()
# Let's select the number of guests
driver.find_element(By.ID, "headlessui-listbox-button-5").click()
guests = driver.find_element(By.ID, "2")
guests.click()
print("Number of guests are selected.")

# Click on check box
check_box_two = driver.find_element_by_name("li2")
check_box_two.click()
# Searching for the results
search = driver.find_element(By.XPATH, "//*[@id='search']")
search.click()
driver.implicitly_wait(3)

# Enter item in textfield
textfield = driver.find_element_by_id("sampletodotext")
textfield.send_keys("Yey, Let's add it to list")
# Let's select one of the hotels for booking
reserve = driver.find_element(By.ID, "reserve-now")
reserve.click()
driver.implicitly_wait(3)
proceed = driver.find_element(By.ID, "proceed")
proceed.click()
driver.implicitly_wait(3)
print("Booking is confirmed.")

# Click on add button
add_button = driver.find_element_by_id("addbutton")
add_button.click()
# Let's download the invoice
download = driver.find_element(By.ID, "invoice")
if (download.is_displayed()):
download.click()
driver.execute_script("lambda-status=passed")
print("Tests are run successfully!")
else:
driver.execute_script("lambda-status=failed")

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

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