Skip to content

Commit d9e8451

Browse files
committed
Add snippet for Ignoring elements
1 parent 677042f commit d9e8451

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

SmartUI_SDK_Ignore.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
from lambdatest_selenium_driver import smartui_snapshot
2+
import unittest
3+
from selenium import webdriver
4+
from selenium.webdriver.common.by import By
5+
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
6+
import os
7+
8+
username = os.getenv("LT_USERNAME") # Replace the username
9+
access_key = os.getenv("LT_ACCESS_KEY") # Replace the access key
10+
class FirstSampleTest(unittest.TestCase):
11+
def setUp(self):
12+
options = webdriver.ChromeOptions()
13+
options.browser_version = "118.0"
14+
options.platform_name = "Windows 11"
15+
lt_options = {};
16+
lt_options["resolution"] = "1024x768";
17+
lt_options["project"] = "Python_SDK";
18+
lt_options["name"] = "Python_Build";
19+
lt_options["w3c"] = True;
20+
lt_options["plugin"] = "python-python";
21+
lt_options["console"] = True
22+
lt_options["network"] = True
23+
lt_options["selenium_version"] = "4.0.0"
24+
options.set_capability('LT:Options', lt_options);
25+
self.driver = webdriver.Remote(
26+
command_executor="http://{}:{}@hub.lambdatest.com/wd/hub".format(
27+
username, access_key),
28+
options=options
29+
)
30+
def tearDown(self):
31+
self.driver.quit()
32+
def test_demo_site(self):
33+
try:
34+
driver = self.driver
35+
driver.implicitly_wait(10)
36+
driver.set_page_load_timeout(30)
37+
print('Loading URL')
38+
options = {
39+
'ignoreDOM': {
40+
'xpath': ['//*[@id="__next"]/div/div[2]/main/section[4]'] #use xpath of your choice
41+
}
42+
}
43+
44+
driver.get('https://ipinfo.io/') #use any website of your choice
45+
46+
smartui_snapshot(driver,"Sample-Ignore",options)
47+
print("1st screenshot")
48+
driver.implicitly_wait(10)
49+
driver.execute_script("lambda-status=passed")
50+
except:
51+
driver.execute_script("lambda-status=failed")
52+
print("Failed")
53+
54+
if __name__ == "__main__":
55+
unittest.main()

0 commit comments

Comments
 (0)