Created
November 8, 2017 12:49
-
-
Save manoj9788/a8153bd7bfec7a7f72776232944f0444 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.applitools.seleniumJavaExamples; | |
import com.applitools.eyes.BatchInfo; | |
import com.applitools.eyes.MatchLevel; | |
import com.applitools.eyes.RectangleSize; | |
import com.applitools.eyes.selenium.Eyes; | |
import com.applitools.eyes.selenium.StitchMode; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.chrome.ChromeOptions; | |
import org.openqa.selenium.remote.DesiredCapabilities; | |
import org.openqa.selenium.remote.RemoteWebDriver; | |
import org.testng.annotations.AfterSuite; | |
import org.testng.annotations.BeforeMethod; | |
import org.testng.annotations.BeforeSuite; | |
import org.testng.annotations.Test; | |
import java.net.URL; | |
import java.util.HashMap; | |
import java.util.concurrent.TimeUnit; | |
public class DisableImagesSauceApplitools { | |
private WebDriver driver; | |
public static BatchInfo batch; | |
private Eyes eyes = new Eyes(); | |
public static final String APPLITOOLS_KEY = "Your-key"; | |
public static final String USERNAME = "username"; | |
public static final String ACCESS_KEY = "Your-key"; | |
public static final String URL = "https://" + USERNAME + ":" + ACCESS_KEY + "@ondemand.saucelabs.com:443/wd/hub"; | |
@BeforeSuite | |
public void before_suite() throws Exception { | |
HashMap<String, Object> images = new HashMap<String, Object>(); | |
images.put("images", 2); | |
HashMap<String, Object> prefs = new HashMap<String, Object>(); | |
prefs.put("profile.default_content_setting_values", images); | |
ChromeOptions options= new ChromeOptions(); | |
options.addArguments("--test-type --no-sandbox"); | |
options.addArguments("--enable-strict-powerful-feature-restrictions"); | |
options.setExperimentalOption("prefs", prefs); | |
DesiredCapabilities caps = DesiredCapabilities.chrome(); | |
caps.setCapability("platform", "macOS 10.12"); | |
caps.setCapability("version", "62.0"); | |
caps.setCapability("screenResolution", "1280x960"); | |
driver = new RemoteWebDriver(new URL(URL), caps); | |
driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS); | |
} | |
@AfterSuite | |
public void after_suite() throws Exception { | |
driver.quit(); | |
} | |
@BeforeMethod | |
public void resetBrowser() { | |
driver.get("about:blank"); | |
eyes.setForceFullPageScreenshot(true); | |
eyes.setStitchMode(StitchMode.CSS); | |
eyes.setMatchLevel(MatchLevel.LAYOUT); | |
eyes.setBatch(batch); | |
} | |
@Test | |
public void my_first_test() throws InterruptedException { | |
driver.get("http://assertselenium.com/"); | |
eyes.open(driver, "my-test-no-images", "images0ff", new RectangleSize(1400, 800)); | |
eyes.checkWindow("homepage-with-no-images"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment