Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 27 additions & 17 deletions lambdatest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import unittest
import os
from selenium import webdriver
Expand All @@ -9,11 +8,11 @@
access_key = os.getenv("LT_ACCESS_KEY") # Replace the access key


#paste your capibility options below
# paste your capibility options below

options = ChromeOptions()
options.browser_version = "114.0"
options.platform_name = "macOS High Sierra"
options.browser_version = "latest"
options.platform_name = "win10"
lt_options = {}
lt_options["username"] = username
lt_options["accessKey"] = access_key
Expand All @@ -26,40 +25,49 @@
lt_options["name"] = "basic_unit_selinium"
lt_options["w3c"] = True
lt_options["plugin"] = "python-python"
options.set_capability('LT:Options', lt_options)
options.set_capability("LT:Options", lt_options)


# Steps to run Smart UI project (https://beta-smartui.lambdatest.com/)
# Step - 1 : Change the hub URL to @beta-smartui-hub.lambdatest.com/wd/hub
# Step - 2 : Add "smartUI.project": "<Project Name>" as a capability above
# Step - 3 : Run "driver.execute_script("smartui.takeScreenshot")" command wherever you need to take a screenshot
# Note: for additional capabilities navigate to https://www.lambdatest.com/support/docs/test-settings-options/

# Steps to run Smart UI project (https://beta-smartui.lambdatest.com/)
# Step - 1 : Change the hub URL to @beta-smartui-hub.lambdatest.com/wd/hub
# Step - 2 : Add "smartUI.project": "<Project Name>" as a capability above
# Step - 3 : Run "driver.execute_script("smartui.takeScreenshot")" command wherever you need to take a screenshot
# Note: for additional capabilities navigate to https://www.lambdatest.com/support/docs/test-settings-options/

class FirstSampleTest(unittest.TestCase):
driver = None

def setUp(self):
driver = webdriver.Remote(command_executor="http://{}:{}@hub.lambdatest.com/wd/hub".format(username, access_key),options=options)
self.driver = webdriver.Remote(
command_executor="http://{}:{}@hub.lambdatest.com/wd/hub".format(
username, access_key
),
options=options,
)

# """ 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)

# Url
print('Loading URL')
driver.get("https://stage-lambda-devops-use-only.lambdatestinternal.com/To-do-app/index.html")
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")

#Take Smart UI screenshot
#driver.execute_script("smartui.takeScreenshot")
# Take Smart UI screenshot
# driver.execute_script("smartui.takeScreenshot")

# Let's add a checkbox
driver.find_element(By.ID, "sampletodotext").send_keys("LambdaTest")
Expand All @@ -82,9 +90,11 @@ def test_demo_site(self):
print("Tests are run successfully!")
else:
driver.execute_script("lambda-status=failed")
# tearDown runs after each test case

# tearDown runs after each test case
def tearDown(self):
self.driver.quit()


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