-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathSmartUI_SDK_Ignore.py
More file actions
55 lines (51 loc) · 2 KB
/
SmartUI_SDK_Ignore.py
File metadata and controls
55 lines (51 loc) · 2 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
53
54
55
from lambdatest_selenium_driver import smartui_snapshot
import unittest
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
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):
def setUp(self):
options = webdriver.ChromeOptions()
options.browser_version = "118.0"
options.platform_name = "Windows 11"
lt_options = {};
lt_options["resolution"] = "1024x768";
lt_options["project"] = "Python_SDK";
lt_options["name"] = "Python_Build";
lt_options["w3c"] = True;
lt_options["plugin"] = "python-python";
lt_options["console"] = True
lt_options["network"] = True
lt_options["selenium_version"] = "4.0.0"
options.set_capability('LT:Options', lt_options);
self.driver = webdriver.Remote(
command_executor="http://{}:{}@hub.lambdatest.com/wd/hub".format(
username, access_key),
options=options
)
def tearDown(self):
self.driver.quit()
def test_demo_site(self):
try:
driver = self.driver
driver.implicitly_wait(10)
driver.set_page_load_timeout(30)
print('Loading URL')
options = {
'ignoreDOM': {
'xpath': ['//*[@id="__next"]/div/div[2]/main/section[4]'] #use xpath of your choice
}
}
driver.get('https://ipinfo.io/') #use any website of your choice
smartui_snapshot(driver,"Sample-Ignore",options)
print("1st screenshot")
driver.implicitly_wait(10)
driver.execute_script("lambda-status=passed")
except:
driver.execute_script("lambda-status=failed")
print("Failed")
if __name__ == "__main__":
unittest.main()