1
-
2
1
import unittest
3
2
import os
4
3
from selenium import webdriver
9
8
access_key = os .getenv ("LT_ACCESS_KEY" ) # Replace the access key
10
9
11
10
12
- #paste your capibility options below
11
+ # paste your capibility options below
13
12
14
13
options = ChromeOptions ()
15
- options .browser_version = "114.0 "
16
- options .platform_name = "macOS High Sierra "
14
+ options .browser_version = "latest "
15
+ options .platform_name = "win10 "
17
16
lt_options = {}
18
17
lt_options ["username" ] = username
19
18
lt_options ["accessKey" ] = access_key
26
25
lt_options ["name" ] = "basic_unit_selinium"
27
26
lt_options ["w3c" ] = True
28
27
lt_options ["plugin" ] = "python-python"
29
- options .set_capability ('LT:Options' , lt_options )
28
+ options .set_capability ("LT:Options" , lt_options )
29
+
30
30
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/
31
36
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/
37
37
38
38
class FirstSampleTest (unittest .TestCase ):
39
+ driver = None
40
+
39
41
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
+ )
41
48
42
49
# """ You can write the test cases here """
43
50
def test_demo_site (self ):
44
-
45
51
# try:
46
52
driver = self .driver
47
53
driver .implicitly_wait (10 )
48
54
driver .set_page_load_timeout (30 )
49
55
driver .set_window_size (1920 , 1080 )
50
56
51
57
# 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
+ )
54
62
55
63
# Let's click on a element
56
64
driver .find_element (By .NAME , "li1" ).click ()
57
65
location = driver .find_element (By .NAME , "li2" )
58
66
location .click ()
59
67
print ("Clicked on the second element" )
60
68
61
- #Take Smart UI screenshot
62
- #driver.execute_script("smartui.takeScreenshot")
69
+ # Take Smart UI screenshot
70
+ # driver.execute_script("smartui.takeScreenshot")
63
71
64
72
# Let's add a checkbox
65
73
driver .find_element (By .ID , "sampletodotext" ).send_keys ("LambdaTest" )
@@ -82,9 +90,11 @@ def test_demo_site(self):
82
90
print ("Tests are run successfully!" )
83
91
else :
84
92
driver .execute_script ("lambda-status=failed" )
85
- # tearDown runs after each test case
93
+
94
+ # tearDown runs after each test case
86
95
def tearDown (self ):
87
96
self .driver .quit ()
88
97
98
+
89
99
if __name__ == "__main__" :
90
100
unittest .main ()
0 commit comments