1
0
mirror of synced 2026-07-27 18:55:23 +00:00

docs: update examples to use set* instead of with* (#325)

This commit is contained in:
Yury Semikhatsky
2021-03-05 14:29:41 -08:00
committed by GitHub
parent 617822fa18
commit 7d333f994e
4 changed files with 21 additions and 21 deletions
@@ -28,18 +28,18 @@ public class MobileAndGeolocation {
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.chromium().launch();
BrowserContext context = browser.newContext(new Browser.NewContextOptions()
.withUserAgent("Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3765.0 Mobile Safari/537.36")
.withViewportSize(411, 731)
.withDeviceScaleFactor(2.625)
.withIsMobile(true)
.withHasTouch(true)
.withLocale("en-US")
.withGeolocation(41.889938, 12.492507)
.withPermissions(asList("geolocation")));
.setUserAgent("Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3765.0 Mobile Safari/537.36")
.setViewportSize(411, 731)
.setDeviceScaleFactor(2.625)
.setIsMobile(true)
.setHasTouch(true)
.setLocale("en-US")
.setGeolocation(41.889938, 12.492507)
.setPermissions(asList("geolocation")));
Page page = context.newPage();
page.navigate("https://www.openstreetmap.org/");
page.click("a[data-original-title=\"Show My Location\"]");
page.screenshot(new Page.ScreenshotOptions().withPath(Paths.get("colosseum-pixel2.png")));
page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("colosseum-pixel2.png")));
}
}
}