Skip to content

Commit 7d333f9

Browse files
authored
docs: update examples to use set* instead of with* (microsoft#325)
1 parent 617822f commit 7d333f9

4 files changed

Lines changed: 21 additions & 21 deletions

File tree

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public class PageScreenshot {
7676
BrowserContext context = browser.newContext();
7777
Page page = context.newPage();
7878
page.navigate("http://whatsmyuseragent.org/");
79-
page.screenshot(new Page.ScreenshotOptions().withPath(Paths.get("screenshot-" + browserType.name() + ".png")));
79+
page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("screenshot-" + browserType.name() + ".png")));
8080
}
8181
}
8282
}
@@ -101,18 +101,18 @@ public class MobileAndGeolocation {
101101
try (Playwright playwright = Playwright.create()) {
102102
Browser browser = playwright.chromium().launch();
103103
BrowserContext context = browser.newContext(new Browser.NewContextOptions()
104-
.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")
105-
.withViewportSize(411, 731)
106-
.withDeviceScaleFactor(2.625)
107-
.withIsMobile(true)
108-
.withHasTouch(true)
109-
.withLocale("en-US")
110-
.withGeolocation(41.889938, 12.492507)
111-
.withPermissions(asList("geolocation")));
104+
.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")
105+
.setViewportSize(411, 731)
106+
.setDeviceScaleFactor(2.625)
107+
.setIsMobile(true)
108+
.setHasTouch(true)
109+
.setLocale("en-US")
110+
.setGeolocation(41.889938, 12.492507)
111+
.setPermissions(asList("geolocation")));
112112
Page page = context.newPage();
113113
page.navigate("https://www.openstreetmap.org/");
114114
page.click("a[data-original-title=\"Show My Location\"]");
115-
page.screenshot(new Page.ScreenshotOptions().withPath(Paths.get("colosseum-pixel2.png")));
115+
page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("colosseum-pixel2.png")));
116116
}
117117
}
118118
}

examples/src/main/java/org/example/MobileAndGeolocation.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ public static void main(String[] args) {
2828
try (Playwright playwright = Playwright.create()) {
2929
Browser browser = playwright.chromium().launch();
3030
BrowserContext context = browser.newContext(new Browser.NewContextOptions()
31-
.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")
32-
.withViewportSize(411, 731)
33-
.withDeviceScaleFactor(2.625)
34-
.withIsMobile(true)
35-
.withHasTouch(true)
36-
.withLocale("en-US")
37-
.withGeolocation(41.889938, 12.492507)
38-
.withPermissions(asList("geolocation")));
31+
.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")
32+
.setViewportSize(411, 731)
33+
.setDeviceScaleFactor(2.625)
34+
.setIsMobile(true)
35+
.setHasTouch(true)
36+
.setLocale("en-US")
37+
.setGeolocation(41.889938, 12.492507)
38+
.setPermissions(asList("geolocation")));
3939
Page page = context.newPage();
4040
page.navigate("https://www.openstreetmap.org/");
4141
page.click("a[data-original-title=\"Show My Location\"]");
42-
page.screenshot(new Page.ScreenshotOptions().withPath(Paths.get("colosseum-pixel2.png")));
42+
page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("colosseum-pixel2.png")));
4343
}
4444
}
4545
}

examples/src/main/java/org/example/PageScreenshot.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static void main(String[] args) {
3535
BrowserContext context = browser.newContext();
3636
Page page = context.newPage();
3737
page.navigate("http://whatsmyuseragent.org/");
38-
page.screenshot(new Page.ScreenshotOptions().withPath(Paths.get("screenshot-" + browserType.name() + ".png")));
38+
page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("screenshot-" + browserType.name() + ".png")));
3939
}
4040
}
4141
}

examples/src/main/java/org/example/WebKitScreenshot.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static void main(String[] args) {
2525
Browser browser = playwright.webkit().launch();
2626
Page page = browser.newPage();
2727
page.navigate("http://whatsmyuseragent.org/");
28-
page.screenshot(new Page.ScreenshotOptions().withPath(Paths.get("example.png")));
28+
page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("example.png")));
2929
}
3030
}
3131
}

0 commit comments

Comments
 (0)