1-
21import unittest
32import os
43from selenium import webdriver
98access_key = os .getenv ("LT_ACCESS_KEY" ) # Replace the access key
109
1110
12- #paste your capibility options below
11+ # paste your capibility options below
1312
1413options = ChromeOptions ()
15- options .browser_version = "114.0 "
16- options .platform_name = "macOS High Sierra "
14+ options .browser_version = "latest "
15+ options .platform_name = "win10 "
1716lt_options = {}
1817lt_options ["username" ] = username
1918lt_options ["accessKey" ] = access_key
2625lt_options ["name" ] = "basic_unit_selinium"
2726lt_options ["w3c" ] = True
2827lt_options ["plugin" ] = "python-python"
29- options .set_capability ('LT:Options' , lt_options )
28+ options .set_capability ("LT:Options" , lt_options )
29+
3030
31+ # Steps to run Smart UI project (https://beta-smartui.lambdatest.com/)
32+ # Step - 1 : Change the hub URL to @beta-smartui-hub.lambdatest.com/wd/hub
33+ # Step - 2 : Add "smartUI.project": "<Project Name>" as a capability above
34+ # Step - 3 : Run "driver.execute_script("smartui.takeScreenshot")" command wherever you need to take a screenshot
35+ # Note: for additional capabilities navigate to https://www.lambdatest.com/support/docs/test-settings-options/
3136
32- # Steps to run Smart UI project (https://beta-smartui.lambdatest.com/)
33- # Step - 1 : Change the hub URL to @beta-smartui-hub.lambdatest.com/wd/hub
34- # Step - 2 : Add "smartUI.project": "<Project Name>" as a capability above
35- # Step - 3 : Run "driver.execute_script("smartui.takeScreenshot")" command wherever you need to take a screenshot
36- # Note: for additional capabilities navigate to https://www.lambdatest.com/support/docs/test-settings-options/
3737
3838class FirstSampleTest (unittest .TestCase ):
39+ driver = None
40+
3941 def setUp (self ):
40- driver = webdriver .Remote (command_executor = "http://{}:{}@hub.lambdatest.com/wd/hub" .format (username , access_key ),options = options )
42+ self .driver = webdriver .Remote (
43+ command_executor = "http://{}:{}@hub.lambdatest.com/wd/hub" .format (
44+ username , access_key
45+ ),
46+ options = options ,
47+ )
4148
4249 # """ You can write the test cases here """
4350 def test_demo_site (self ):
44-
4551 # try:
4652 driver = self .driver
4753 driver .implicitly_wait (10 )
4854 driver .set_page_load_timeout (30 )
4955 driver .set_window_size (1920 , 1080 )
5056
5157 # Url
52- print ('Loading URL' )
53- driver .get ("https://stage-lambda-devops-use-only.lambdatestinternal.com/To-do-app/index.html" )
58+ print ("Loading URL" )
59+ driver .get (
60+ "https://stage-lambda-devops-use-only.lambdatestinternal.com/To-do-app/index.html"
61+ )
5462
5563 # Let's click on a element
5664 driver .find_element (By .NAME , "li1" ).click ()
5765 location = driver .find_element (By .NAME , "li2" )
5866 location .click ()
5967 print ("Clicked on the second element" )
6068
61- #Take Smart UI screenshot
62- #driver.execute_script("smartui.takeScreenshot")
69+ # Take Smart UI screenshot
70+ # driver.execute_script("smartui.takeScreenshot")
6371
6472 # Let's add a checkbox
6573 driver .find_element (By .ID , "sampletodotext" ).send_keys ("LambdaTest" )
@@ -82,9 +90,11 @@ def test_demo_site(self):
8290 print ("Tests are run successfully!" )
8391 else :
8492 driver .execute_script ("lambda-status=failed" )
85- # tearDown runs after each test case
93+
94+ # tearDown runs after each test case
8695 def tearDown (self ):
8796 self .driver .quit ()
8897
98+
8999if __name__ == "__main__" :
90100 unittest .main ()
0 commit comments