|
| 1 | +package com.lambdatest.sdk; |
| 2 | + |
| 3 | +import io.github.lambdatest.SmartUISnapshot; |
| 4 | +import org.openqa.selenium.remote.DesiredCapabilities; |
| 5 | +import org.openqa.selenium.remote.RemoteWebDriver; |
| 6 | +import org.testng.ITestContext; |
| 7 | +import org.testng.annotations.AfterMethod; |
| 8 | +import org.testng.annotations.BeforeMethod; |
| 9 | +import org.testng.annotations.Test; |
| 10 | + |
| 11 | +import java.lang.reflect.Method; |
| 12 | +import java.net.MalformedURLException; |
| 13 | +import java.net.URL; |
| 14 | +import java.util.Arrays; |
| 15 | +import java.util.HashMap; |
| 16 | +import java.util.List; |
| 17 | +import java.util.Map; |
| 18 | + |
| 19 | +public class SmartUIIgnoreSelectSDKCould { |
| 20 | + |
| 21 | + |
| 22 | + private RemoteWebDriver driver; |
| 23 | + private String Status = "failed"; |
| 24 | + private String githubURL = System.getenv("GITHUB_URL"); |
| 25 | + |
| 26 | + @BeforeMethod |
| 27 | + public void setup(Method m, ITestContext ctx) throws MalformedURLException { |
| 28 | + String username = System.getenv("LT_USERNAME") == null ? "Your LT Username" : System.getenv("LT_USERNAME"); |
| 29 | + String authkey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" : System.getenv("LT_ACCESS_KEY"); |
| 30 | + String hub = "@hub.lambdatest.com/wd/hub"; |
| 31 | + |
| 32 | + DesiredCapabilities caps = new DesiredCapabilities(); |
| 33 | + caps.setCapability("platform", "Catalina"); |
| 34 | + caps.setCapability("browserName", "chrome"); |
| 35 | + caps.setCapability("version", "latest"); |
| 36 | + caps.setCapability("build", "TestNG With Java"); |
| 37 | + caps.setCapability("name", m.getName() + " - " + this.getClass().getName()); |
| 38 | + |
| 39 | + if (githubURL != null) { |
| 40 | + Map<String, String> github = new HashMap<String, String>(); |
| 41 | + github.put("url",githubURL); |
| 42 | + caps.setCapability("github", github); |
| 43 | + } |
| 44 | + System.out.println(caps); |
| 45 | + driver = new RemoteWebDriver(new URL("https://" + username + ":" + authkey + hub), caps); |
| 46 | + |
| 47 | + } |
| 48 | + |
| 49 | + @Test |
| 50 | + public void basicTest() throws Exception { |
| 51 | + Map<String, Object> ignoreOptions = new HashMap<>(); |
| 52 | + List<String> ignoreID = Arrays.asList("api-requests"); |
| 53 | + List<String> ignoreCSSSelectors = Arrays.asList(".overflow-hidden section:first-of-type", |
| 54 | + ".overflow-hidden section:nth-of-type(2)", "section:nth-of-type(6) .swiper", "section:nth-of-type(7) .swiper"); |
| 55 | + Map<String, List<String>> ignoreDOM = new HashMap<>(); |
| 56 | + ignoreDOM.put("id", ignoreID); |
| 57 | + ignoreDOM.put("cssSelector", ignoreCSSSelectors); |
| 58 | + ignoreOptions.put("ignoreDOM", ignoreDOM); |
| 59 | + |
| 60 | + Map<String, Object> selectOptions = new HashMap<>(); |
| 61 | + List<String> selectID = Arrays.asList(""); |
| 62 | + List<String> selectCSSSelectors = Arrays.asList("h1.heading-h1"); |
| 63 | + Map<String, List<String>> selectDOM = new HashMap<>(); |
| 64 | + selectDOM.put("cssSelector", selectCSSSelectors); |
| 65 | + selectOptions.put("selectDOM", selectDOM); |
| 66 | + |
| 67 | + System.out.println("Loading Url"); |
| 68 | + driver.get("https://ipinfo.io/"); |
| 69 | + SmartUISnapshot.smartuiSnapshot(driver, "ignoreOptionsScreenshot", ignoreOptions); |
| 70 | + Thread.sleep(2000); |
| 71 | + SmartUISnapshot.smartuiSnapshot(driver, "selectOptionsScreenshot", selectOptions); |
| 72 | + Thread.sleep(1000); |
| 73 | + System.out.println("Test Finished"); |
| 74 | + } |
| 75 | + |
| 76 | + @AfterMethod |
| 77 | + public void tearDown() { |
| 78 | + driver.executeScript("lambda-status=" + Status); |
| 79 | + driver.quit(); |
| 80 | + } |
| 81 | +} |
0 commit comments