Skip to content

Commit 02b3af6

Browse files
authored
Merge branch 'trunk' into 4_22
2 parents bd7f5d0 + 795d542 commit 02b3af6

Some content is hidden

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

55 files changed

+622
-626
lines changed

examples/dotnet/SeleniumDocs/BaseTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class BaseTest
1717
protected IWebDriver driver;
1818
protected Uri GridUrl;
1919
private Process _webserverProcess;
20-
private const string ServerJarName = "selenium-server-4.21.0.jar";
20+
private const string ServerJarName = "selenium-server-4.22.0.jar";
2121
private static readonly string BaseDirectory = AppContext.BaseDirectory;
2222
private const string RelativePathToGrid = "../../../../../";
2323
private readonly string _examplesDirectory = Path.GetFullPath(Path.Combine(BaseDirectory, RelativePathToGrid));
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,49 @@
1+
using System;
12
using Microsoft.VisualStudio.TestTools.UnitTesting;
2-
3+
using OpenQA.Selenium;
4+
using OpenQA.Selenium.Chrome;
5+
using System.Collections.Generic;
36
namespace SeleniumDocs.Interactions
47
{
58
[TestClass]
6-
public class WindowsTest : BaseTest
9+
public class WindowsTest
710
{
11+
[TestMethod]
12+
public void TestWindowCommands()
13+
{
14+
WebDriver driver = new ChromeDriver();
15+
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500);
16+
17+
// Navigate to Url
18+
driver.Url="https://www.selenium.dev/selenium/web/window_switching_tests/page_with_frame.html";
19+
//fetch handle of this
20+
String currHandle = driver.CurrentWindowHandle;
21+
Assert.IsNotNull(currHandle);
22+
23+
//click on link to open a new window
24+
driver.FindElement(By.LinkText("Open new window")).Click();
25+
//fetch handles of all windows, there will be two, [0]- default, [1] - new window
26+
IList<string> windowHandles = new List<string>(driver.WindowHandles);
27+
driver.SwitchTo().Window(windowHandles[1]);
28+
//assert on title of new window
29+
String title = driver.Title;
30+
Assert.AreEqual("Simple Page", title);
31+
32+
//closing current window
33+
driver.Close();
34+
//Switch back to the old tab or window
35+
driver.SwitchTo().Window(windowHandles[0]);
36+
37+
//Opens a new tab and switches to new tab
38+
driver.SwitchTo().NewWindow(WindowType.Tab);
39+
Assert.AreEqual("", driver.Title);
40+
41+
//Opens a new window and switches to new window
42+
driver.SwitchTo().NewWindow(WindowType.Window);
43+
Assert.AreEqual("", driver.Title);
44+
45+
//quitting driver
46+
driver.Quit(); //close all windows
47+
}
848
}
9-
}
49+
}

examples/dotnet/SeleniumDocs/SeleniumDocs.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<ItemGroup>
99
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
10-
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="7.6.0" />
10+
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="7.6.3" />
1111
<PackageReference Include="MSTest.TestAdapter" Version="3.4.3" />
1212
<PackageReference Include="MSTest.TestFramework" Version="3.4.3" />
1313
<PackageReference Include="Selenium.Support" Version="4.22.0" />

examples/java/README.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Running Selenium Java Tests
2+
The following steps will guide you on how to
3+
run Selenium Java tests using a repository
4+
of `SeleniumHQ/seleniumhq.github.io` examples.
5+
6+
## Initial Setup
7+
8+
### Prerequisites
9+
10+
Ensure that Java Development Kit (JDK) and Maven
11+
are installed on your system. If they are not installed,
12+
you will need to download and install them. You can
13+
find detailed installation guides for both on their
14+
respective official sites.
15+
16+
### Clone the repository
17+
First, we need to get the Selenium Java examples
18+
on your local machine. This can be done by
19+
cloning the `SeleniumHQ/seleniumhq.github.io` Git repository.
20+
Run the following command in your terminal:
21+
22+
```bash
23+
git clone https://github.com/SeleniumHQ/seleniumhq.github.io.git
24+
```
25+
## Navigate to the java directory
26+
After cloning the repository, navigate into the
27+
directory where the Selenium Java examples are
28+
located. Run the following command:
29+
30+
```bash
31+
cd seleniumhq.github.io/examples/java
32+
```
33+
34+
## Running the Tests
35+
### Install dependencies
36+
Before running the tests, we need to install all
37+
necessary dependencies. Maven, a software
38+
project management tool, can do this for us.
39+
Run the following command:
40+
41+
```bash
42+
mvn test-compile
43+
```
44+
45+
### Run all tests
46+
To verify if everything is installed correctly and
47+
functioning properly, we should run all
48+
available tests. This can be done with the following command:
49+
50+
```bash
51+
mvn test
52+
```
53+
54+
Please be patient! If this is your first time running these tests,
55+
it might take a while to download and verify all necessary browser drivers.
56+
57+
## Execute a specific example
58+
To run a specific Selenium Java example, use the following command:
59+
```bash
60+
mvn exec:java -D"exec.mainClass"="dev.selenium.getting_started.FirstScript" -D"exec.classpathScope"=test
61+
```
62+
63+
Make sure to replace `dev.selenium.getting_started.FirstScript` with the path and name of the example you want to run.

examples/java/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ repositories {
1010
}
1111

1212
dependencies {
13-
testImplementation 'org.seleniumhq.selenium:selenium-java:4.21.0'
14-
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
13+
testImplementation 'org.seleniumhq.selenium:selenium-java:4.22.0'
14+
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.10.3'
1515
}
1616

1717
test {

examples/java/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

examples/java/gradlew

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
# Darwin, MinGW, and NonStop.
5656
#
5757
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
58+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5959
# within the Gradle project.
6060
#
6161
# You can find Gradle at https://github.com/gradle/gradle/.

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.10.2</version>
43+
<version>5.10.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.2.5</version>
58+
<version>3.3.0</version>
5959
<configuration>
6060
<properties>
6161
<configurationParameters>

0 commit comments

Comments
 (0)