forked from LambdaTest/smartui-python-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
52 lines (42 loc) · 1.74 KB
/
test.py
File metadata and controls
52 lines (42 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import unittest
from selenium import webdriver
import os
username = os.getenv("LT_USERNAME") # Replace the username
access_key = os.getenv("LT_ACCESS_KEY") # Replace the access key
class FirstSampleTest(unittest.TestCase):
# Generate capabilities from here: https://www.lambdatest.com/capabilities-generator/
# setUp runs before each test case and
def setUp(self):
chrome_options = webdriver.ChromeOptions()
option = {
"build": 'PyunitTest sample build', # Change your build name here
"name": 'Py-unittest', # Change your test name here
"browserName": 'Chrome',
"version": 'latest',
"platform": 'Windows 11',
# "resolution": '1024x768', # change the resolution
"network": 'true', # Enable or disable network logs
"smartUI.project": "Testing-Smart-UI"
# Build name for smartUI(optional)
# "smartUI.build" : "buildName"
}
chrome_options.set_capability("LT:Options", option)
self.driver = webdriver.Remote(
command_executor="https://{}:{}@hub.lambdatest.com/wd/hub".format(
username, access_key),
options = chrome_options
)
# 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):
# try:
driver = self.driver
# Url
driver.get("https://lambdatest.com")
print("Taking screenshot")
driver.execute_script("smartui.takeScreenshot,{\"screenshotName\":\"sample-screenshot-1\"}")
print("screenshot taken successfully")
if __name__ == "__main__":
unittest.main()