Skip to content

Commit 64fae4b

Browse files
authored
Merge branch 'trunk' into update-python-locators-docs
2 parents dd4d3e7 + 7790733 commit 64fae4b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2522
-324
lines changed

Diff for: .github/workflows/link-check.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242

4343
- name: Link check
4444
continue-on-error: true # <- If set to false, run fails with broken links
45-
uses: untitaker/[email protected].32
45+
uses: untitaker/[email protected].35
4646
with:
4747
args: website_and_docs/public/ --check-anchors
4848

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
using System;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using OpenQA.Selenium;
4+
using OpenQA.Selenium.Chrome;
5+
6+
namespace SeleniumDocumentation.SeleniumInteractions
7+
{
8+
[TestClass]
9+
public class PrintOptionsTest
10+
{
11+
[TestMethod]
12+
public void TestOrientation()
13+
{
14+
IWebDriver driver = new ChromeDriver();
15+
driver.Navigate().GoToUrl("https://selenium.dev");
16+
PrintOptions printOptions = new PrintOptions();
17+
printOptions.Orientation = PrintOrientation.Landscape;
18+
PrintOrientation currentOrientation = printOptions.Orientation;
19+
}
20+
21+
[TestMethod]
22+
public void TestRange()
23+
{
24+
IWebDriver driver = new ChromeDriver();
25+
driver.Navigate().GoToUrl("https://selenium.dev");
26+
PrintOptions printOptions = new PrintOptions();
27+
printOptions.AddPageRangeToPrint("1-3"); // add range of pages
28+
printOptions.AddPageToPrint(5); // add individual page
29+
}
30+
31+
[TestMethod]
32+
public void TestSize()
33+
{
34+
IWebDriver driver = new ChromeDriver();
35+
driver.Navigate().GoToUrl("https://www.selenium.dev/");
36+
PrintOptions printOptions = new PrintOptions();
37+
PrintOptions.PageSize currentDimensions = printOptions.PageDimensions;
38+
}
39+
40+
[TestMethod]
41+
public void TestBackgrounds()
42+
{
43+
IWebDriver driver = new ChromeDriver();
44+
driver.Navigate().GoToUrl("https://www.selenium.dev/");
45+
PrintOptions printOptions = new PrintOptions();
46+
printOptions.OutputBackgroundImages = true;
47+
bool currentBackgrounds = printOptions.OutputBackgroundImages;
48+
}
49+
50+
[TestMethod]
51+
public void TestMargins()
52+
{
53+
IWebDriver driver = new ChromeDriver();
54+
driver.Navigate().GoToUrl("https://www.selenium.dev/");
55+
PrintOptions printOptions = new PrintOptions();
56+
PrintOptions.Margins currentMargins = printOptions.PageMargins;
57+
}
58+
59+
60+
[TestMethod]
61+
public void TestScale()
62+
{
63+
IWebDriver driver = new ChromeDriver();
64+
driver.Navigate().GoToUrl("https://www.selenium.dev/");
65+
PrintOptions printOptions = new PrintOptions();
66+
printOptions.ScaleFactor = 0.5;
67+
double currentScale = printOptions.ScaleFactor;
68+
}
69+
70+
[TestMethod]
71+
public void TestShrinkToFit()
72+
{
73+
IWebDriver driver = new ChromeDriver();
74+
driver.Navigate().GoToUrl("https://www.selenium.dev/");
75+
PrintOptions printOptions = new PrintOptions();
76+
printOptions.ShrinkToFit = true;
77+
bool currentShrinkToFit = printOptions.ShrinkToFit;
78+
}
79+
}
80+
81+
}

Diff for: examples/java/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repositories {
1111

1212
dependencies {
1313
testImplementation 'org.seleniumhq.selenium:selenium-java:4.25.0'
14-
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.11.0'
14+
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.11.3'
1515
}
1616

1717
test {

Diff for: examples/java/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<dependency>
4141
<groupId>org.junit.jupiter</groupId>
4242
<artifactId>junit-jupiter-engine</artifactId>
43-
<version>5.11.0</version>
43+
<version>5.11.3</version>
4444
<scope>test</scope>
4545
</dependency>
4646
<dependency>
@@ -55,7 +55,7 @@
5555
<plugin>
5656
<groupId>org.apache.maven.plugins</groupId>
5757
<artifactId>maven-surefire-plugin</artifactId>
58-
<version>3.5.0</version>
58+
<version>3.5.1</version>
5959
<configuration>
6060
<properties>
6161
<configurationParameters>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package dev.selenium.interactions;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.openqa.selenium.print.PageMargin;
5+
import org.openqa.selenium.print.PrintOptions;
6+
7+
import dev.selenium.BaseChromeTest;
8+
9+
public class PrintOptionsTest extends BaseChromeTest {
10+
11+
@Test
12+
public void TestOrientation()
13+
{
14+
driver.get("https://www.selenium.dev/");
15+
PrintOptions printOptions = new PrintOptions();
16+
printOptions.setOrientation(PrintOptions.Orientation.LANDSCAPE);
17+
PrintOptions.Orientation current_orientation = printOptions.getOrientation();
18+
}
19+
20+
@Test
21+
public void TestRange()
22+
{
23+
driver.get("https://www.selenium.dev/");
24+
PrintOptions printOptions = new PrintOptions();
25+
printOptions.setPageRanges("1-2");
26+
String[] current_range = printOptions.getPageRanges();
27+
}
28+
29+
@Test
30+
public void TestSize()
31+
{
32+
driver.get("https://www.selenium.dev/");
33+
PrintOptions printOptions = new PrintOptions();
34+
printOptions.setScale(.50);
35+
double current_scale = printOptions.getScale();
36+
}
37+
38+
@Test
39+
public void TestMargins()
40+
{
41+
driver.get("https://www.selenium.dev/");
42+
PrintOptions printOptions = new PrintOptions();
43+
PageMargin margins = new PageMargin(1.0,1.0,1.0,1.0);
44+
printOptions.setPageMargin(margins);
45+
double topMargin = margins.getTop();
46+
double bottomMargin = margins.getBottom();
47+
double leftMargin = margins.getLeft();
48+
double rightMargin = margins.getRight();
49+
}
50+
51+
@Test
52+
public void TestScale()
53+
{
54+
driver.get("https://www.selenium.dev/");
55+
PrintOptions printOptions = new PrintOptions();
56+
printOptions.setScale(.50);
57+
double current_scale = printOptions.getScale();
58+
}
59+
60+
@Test
61+
public void TestBackground()
62+
{
63+
driver.get("https://www.selenium.dev/");
64+
PrintOptions printOptions = new PrintOptions();
65+
printOptions.setBackground(true);
66+
boolean current_background = printOptions.getBackground();
67+
}
68+
69+
@Test
70+
public void TestShrinkToFit()
71+
{
72+
driver.get("https://www.selenium.dev/");
73+
PrintOptions printOptions = new PrintOptions();
74+
printOptions.setShrinkToFit(true);
75+
boolean current_shrink_to_fit = printOptions.getShrinkToFit();
76+
}
77+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package dev.selenium.interactions;
2+
3+
import org.openqa.selenium.Pdf;
4+
import org.openqa.selenium.bidi.browsingcontext.BrowsingContext;
5+
import org.junit.jupiter.api.Test;
6+
import org.junit.jupiter.api.Assertions;
7+
import org.junit.jupiter.api.BeforeEach;
8+
import org.openqa.selenium.print.PageMargin;
9+
import org.openqa.selenium.print.PrintOptions;
10+
import org.openqa.selenium.chrome.ChromeOptions;
11+
import org.openqa.selenium.chrome.ChromeDriver;
12+
import org.openqa.selenium.PrintsPage;
13+
import dev.selenium.BaseTest;
14+
15+
public class PrintsPageTest extends BaseTest{
16+
17+
@BeforeEach
18+
public void setup() {
19+
ChromeOptions options = new ChromeOptions();
20+
options.setCapability("webSocketUrl", true);
21+
driver = new ChromeDriver(options);
22+
}
23+
24+
@Test
25+
public void PrintWithPrintsPageTest()
26+
{
27+
driver.get("https://www.selenium.dev/");
28+
PrintsPage printer = (PrintsPage) driver;
29+
PrintOptions printOptions = new PrintOptions();
30+
Pdf printedPage = printer.print(printOptions);
31+
Assertions.assertNotNull(printedPage);
32+
}
33+
34+
@Test
35+
public void PrintWithBrowsingContextTest()
36+
{
37+
BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle());
38+
driver.get("https://www.selenium.dev/selenium/web/formPage.html");
39+
PrintOptions printOptions = new PrintOptions();
40+
String printPage = browsingContext.print(printOptions);
41+
Assertions.assertTrue(printPage.length() > 0);
42+
}
43+
}

Diff for: examples/kotlin/pom.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
<version>1.0.0</version>
1010

1111
<properties>
12-
<kotlin.version>2.0.20</kotlin.version>
12+
<kotlin.version>2.0.21</kotlin.version>
1313

1414
<slf4j.version>2.0.16</slf4j.version>
15-
<logback.version>1.5.8</logback.version>
15+
<logback.version>1.5.11</logback.version>
1616

17-
<junit5.version>5.11.0</junit5.version>
17+
<junit5.version>5.11.3</junit5.version>
1818
<wdm.version>5.2.3</wdm.version>
1919

20-
<maven-surefire-plugin.version>3.5.0</maven-surefire-plugin.version>
20+
<maven-surefire-plugin.version>3.5.1</maven-surefire-plugin.version>
2121

2222
<java.version>1.8</java.version>
2323
<selenium.version>4.25.0</selenium.version>
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import pytest
2+
from selenium import webdriver
3+
from selenium.webdriver.common.print_page_options import PrintOptions
4+
5+
@pytest.fixture()
6+
def driver():
7+
driver = webdriver.Chrome()
8+
yield driver
9+
driver.quit()
10+
11+
def test_orientation(driver):
12+
driver.get("https://www.selenium.dev/")
13+
print_options = PrintOptions()
14+
print_options.orientation = "landscape" ## landscape or portrait
15+
assert print_options.orientation == "landscape"
16+
17+
def test_range(driver):
18+
driver.get("https://www.selenium.dev/")
19+
print_options = PrintOptions()
20+
print_options.page_ranges = ["1, 2, 3"] ## ["1", "2", "3"] or ["1-3"]
21+
assert print_options.page_ranges == ["1, 2, 3"]
22+
23+
def test_size(driver):
24+
driver.get("https://www.selenium.dev/")
25+
print_options = PrintOptions()
26+
print_options.scale = 0.5 ## 0.1 to 2.0``
27+
assert print_options.scale == 0.5
28+
29+
def test_margin(driver):
30+
driver.get("https://www.selenium.dev/")
31+
print_options = PrintOptions()
32+
print_options.margin_top = 10
33+
print_options.margin_bottom = 10
34+
print_options.margin_left = 10
35+
print_options.margin_right = 10
36+
assert print_options.margin_top == 10
37+
assert print_options.margin_bottom == 10
38+
assert print_options.margin_left == 10
39+
assert print_options.margin_right == 10
40+
41+
def test_scale(driver):
42+
driver.get("https://www.selenium.dev/")
43+
print_options = PrintOptions()
44+
print_options.scale = 0.5 ## 0.1 to 2.0
45+
current_scale = print_options.scale
46+
assert current_scale == 0.5
47+
48+
def test_background(driver):
49+
driver.get("https://www.selenium.dev/")
50+
print_options = PrintOptions()
51+
print_options.background = True ## True or False
52+
assert print_options.background is True
53+
54+
def test_shrink_to_fit(driver):
55+
driver.get("https://www.selenium.dev/")
56+
print_options = PrintOptions()
57+
print_options.shrink_to_fit = True ## True or False
58+
assert print_options.shrink_to_fit is True

Diff for: examples/ruby/Gemfile.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ GEM
2929
diff-lcs (>= 1.2.0, < 2.0)
3030
rspec-support (~> 3.13.0)
3131
rspec-support (3.13.0)
32-
rubocop (1.66.1)
32+
rubocop (1.67.0)
3333
json (~> 2.3)
3434
language_server-protocol (>= 3.17.0)
3535
parallel (~> 1.10)
@@ -41,7 +41,7 @@ GEM
4141
unicode-display_width (>= 2.4.0, < 3.0)
4242
rubocop-ast (1.32.3)
4343
parser (>= 3.3.1.0)
44-
rubocop-rspec (3.0.5)
44+
rubocop-rspec (3.1.0)
4545
rubocop (~> 1.61)
4646
ruby-progressbar (1.13.0)
4747
rubyzip (2.3.2)
@@ -53,7 +53,7 @@ GEM
5353
rexml (~> 3.2, >= 3.2.5)
5454
rubyzip (>= 1.2.2, < 3.0)
5555
websocket (~> 1.0)
56-
unicode-display_width (2.5.0)
56+
unicode-display_width (2.6.0)
5757
websocket (1.2.11)
5858

5959
PLATFORMS

Diff for: website_and_docs/content/blog/2023/selenium-4-11-0-released.md

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ Links to everything can be found on our [downloads page][downloads].
6868
<div class="d-flex justify-content-center">
6969
<div class="col-11 p-4 bg-transparent">
7070
<div class="row justify-content-center">
71-
{{< gh-user "https://api.github.com/users/RevealOscar" >}}
7271
{{< gh-user "https://api.github.com/users/mdmintz" >}}
7372
{{< gh-user "https://api.github.com/users/nvborisenko" >}}
7473
{{< gh-user "https://api.github.com/users/sandeepsuryaprasad" >}}

Diff for: website_and_docs/content/blog/2023/selenium-4-13-0-released.md

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ Please upgrade to at least Java 11.
7575
<div class="row justify-content-center">
7676
{{< gh-user "https://api.github.com/users/JefferyVin" >}}
7777
{{< gh-user "https://api.github.com/users/KrishnaSuravarapu" >}}
78-
{{< gh-user "https://api.github.com/users/RevealOscar" >}}
7978
{{< gh-user "https://api.github.com/users/Sean-Gomez" >}}
8079
{{< gh-user "https://api.github.com/users/manuelsblanco" >}}
8180
{{< gh-user "https://api.github.com/users/mdmintz" >}}

Diff for: website_and_docs/content/blog/2023/selenium-4-16-released.md

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ Links to everything can be found on our [downloads page][downloads].
7373
<div class="col-11 p-4 bg-transparent">
7474
<div class="row justify-content-center">
7575
{{< gh-user "https://api.github.com/users/EdwinVanVliet" >}}
76-
{{< gh-user "https://api.github.com/users/RevealOscar" >}}
7776
{{< gh-user "https://api.github.com/users/aguspe" >}}
7877
{{< gh-user "https://api.github.com/users/asottile" >}}
7978
{{< gh-user "https://api.github.com/users/centic9" >}}

Diff for: website_and_docs/content/blog/2024/selenium-4-17-released.md

-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ but you should still switch to `--headless=new` (see: [Headless is going away](/
9696
<div class="row justify-content-center">
9797
<div class="col-11 p-4 bg-transparent">
9898
<div class="row justify-content-center">
99-
{{< gh-user "https://api.github.com/users/RevealOscar" >}}
10099
{{< gh-user "https://api.github.com/users/YevgeniyShunevych" >}}
101100
</div>
102101
</div>

Diff for: website_and_docs/content/blog/2024/selenium-4-18-released.md

-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ but you should still switch to `--headless=new` (see: [Headless is going away](/
7474
<div class="d-flex justify-content-center">
7575
<div class="col-11 p-4 bg-transparent">
7676
<div class="row justify-content-center">
77-
{{< gh-user "https://api.github.com/users/RevealOscar" >}}
7877
{{< gh-user "https://api.github.com/users/Trigtrig" >}}
7978
{{< gh-user "https://api.github.com/users/manuelsblanco" >}}
8079
{{< gh-user "https://api.github.com/users/mtrea" >}}

0 commit comments

Comments
 (0)