Skip to content

Commit

Permalink
Merge branch 'trunk' into update-browsing-context-create
Browse files Browse the repository at this point in the history
  • Loading branch information
pujagani authored Apr 3, 2024
2 parents 8ffee84 + 911b312 commit dbcf179
Show file tree
Hide file tree
Showing 40 changed files with 1,650 additions and 35 deletions.
2 changes: 2 additions & 0 deletions dotnet/test/common/ClearTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public void WritableTextInputShouldClear()

[Test]
[IgnoreBrowser(Browser.Chrome, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")]
[IgnoreBrowser(Browser.Edge, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")]
public void TextInputShouldNotClearWhenDisabled()
{
driver.Url = readOnlyPage;
Expand Down Expand Up @@ -44,6 +45,7 @@ public void WritableTextAreaShouldClear()

[Test]
[IgnoreBrowser(Browser.Chrome, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")]
[IgnoreBrowser(Browser.Edge, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")]
public void TextAreaShouldNotClearWhenDisabled()
{
driver.Url = readOnlyPage;
Expand Down
8 changes: 8 additions & 0 deletions dotnet/test/common/ElementFindingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ public void ShouldThrowAnExceptionWhenThereIsNoLinkToClick()

[Test]
[IgnoreBrowser(Browser.Chrome, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")]
[IgnoreBrowser(Browser.Edge, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")]
public void ShouldThrowInvalidSelectorExceptionWhenXPathIsSyntacticallyInvalidInDriverFindElement()
{
driver.Url = formsPage;
Expand All @@ -447,6 +448,7 @@ public void ShouldThrowInvalidSelectorExceptionWhenXPathIsSyntacticallyInvalidIn

[Test]
[IgnoreBrowser(Browser.Chrome, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")]
[IgnoreBrowser(Browser.Edge, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")]
public void ShouldThrowInvalidSelectorExceptionWhenXPathIsSyntacticallyInvalidInDriverFindElements()
{
if (TestUtilities.IsIE6(driver))
Expand All @@ -461,6 +463,7 @@ public void ShouldThrowInvalidSelectorExceptionWhenXPathIsSyntacticallyInvalidIn

[Test]
[IgnoreBrowser(Browser.Chrome, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")]
[IgnoreBrowser(Browser.Edge, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")]
public void ShouldThrowInvalidSelectorExceptionWhenXPathIsSyntacticallyInvalidInElementFindElement()
{
driver.Url = formsPage;
Expand All @@ -470,6 +473,7 @@ public void ShouldThrowInvalidSelectorExceptionWhenXPathIsSyntacticallyInvalidIn

[Test]
[IgnoreBrowser(Browser.Chrome, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")]
[IgnoreBrowser(Browser.Edge, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")]
public void ShouldThrowInvalidSelectorExceptionWhenXPathIsSyntacticallyInvalidInElementFindElements()
{
driver.Url = formsPage;
Expand All @@ -479,6 +483,7 @@ public void ShouldThrowInvalidSelectorExceptionWhenXPathIsSyntacticallyInvalidIn

[Test]
[IgnoreBrowser(Browser.Chrome, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")]
[IgnoreBrowser(Browser.Edge, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")]
public void ShouldThrowInvalidSelectorExceptionWhenXPathReturnsWrongTypeInDriverFindElement()
{
driver.Url = formsPage;
Expand All @@ -487,6 +492,7 @@ public void ShouldThrowInvalidSelectorExceptionWhenXPathReturnsWrongTypeInDriver

[Test]
[IgnoreBrowser(Browser.Chrome, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")]
[IgnoreBrowser(Browser.Edge, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")]
public void ShouldThrowInvalidSelectorExceptionWhenXPathReturnsWrongTypeInDriverFindElements()
{
if (TestUtilities.IsIE6(driver))
Expand All @@ -501,6 +507,7 @@ public void ShouldThrowInvalidSelectorExceptionWhenXPathReturnsWrongTypeInDriver

[Test]
[IgnoreBrowser(Browser.Chrome, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")]
[IgnoreBrowser(Browser.Edge, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")]
public void ShouldThrowInvalidSelectorExceptionWhenXPathReturnsWrongTypeInElementFindElement()
{
driver.Url = formsPage;
Expand All @@ -511,6 +518,7 @@ public void ShouldThrowInvalidSelectorExceptionWhenXPathReturnsWrongTypeInElemen

[Test]
[IgnoreBrowser(Browser.Chrome, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")]
[IgnoreBrowser(Browser.Edge, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")]
public void ShouldThrowInvalidSelectorExceptionWhenXPathReturnsWrongTypeInElementFindElements()
{
if (TestUtilities.IsIE6(driver))
Expand Down
22 changes: 2 additions & 20 deletions dotnet/test/common/WebDriver.Common.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@
<RootNamespace>OpenQA.Selenium</RootNamespace>
</PropertyGroup>

<ItemGroup>
<Compile Remove="obj\**" />
<EmbeddedResource Remove="obj\**" />
<None Remove="obj\**" />
</ItemGroup>

<ItemGroup>
<Compile Remove="Properties\AssemblyInfo.cs" />
</ItemGroup>

<ItemGroup>
<None Remove="Settings.StyleCop" />
</ItemGroup>
Expand All @@ -37,22 +27,14 @@
<ProjectReference Include="..\..\src\webdriver\WebDriver.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>

<ItemGroup>
<None Update="appconfig.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent" Condition="'$(OS)' == 'Windows_NT'">
<Exec Command="call &quot;$(ProjectDir)WebDriver.Common.Tests.csproj.prebuild.cmd&quot; &quot;$(ProjectDir)&quot;" />
</Target>

<Target Name="PreBuildNonWindows" BeforeTargets="PreBuildEvent" Condition="'$(OS)' != 'Windows_NT'">
<Exec Command="$(ProjectDir)WebDriver.Common.Tests.csproj.prebuild.sh $(ProjectDir)" />
<Target Name="BuildTestWebServer" AfterTargets="AfterBuild">
<Exec Command="bazel build //java/test/org/openqa/selenium/environment:appserver_deploy.jar" />
</Target>

<!-- It is automatically imported when Selenium.WebDriver consumed via nuget package -->
Expand Down
2 changes: 0 additions & 2 deletions dotnet/test/common/WebDriver.Common.Tests.csproj.prebuild.cmd

This file was deleted.

3 changes: 0 additions & 3 deletions dotnet/test/common/WebDriver.Common.Tests.csproj.prebuild.sh

This file was deleted.

3 changes: 3 additions & 0 deletions java/test/org/openqa/selenium/ClearTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.openqa.selenium.testing.drivers.Browser.CHROME;
import static org.openqa.selenium.testing.drivers.Browser.EDGE;
import static org.openqa.selenium.testing.drivers.Browser.IE;

import org.junit.jupiter.api.Test;
Expand All @@ -39,6 +40,7 @@ void testWritableTextInputShouldClear() {

@Test
@Ignore(value = CHROME, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
@Ignore(value = EDGE, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
void testTextInputShouldNotClearWhenDisabled() {
driver.get(pages.readOnlyPage);
WebElement element = driver.findElement(By.id("textInputNotEnabled"));
Expand All @@ -63,6 +65,7 @@ void testWritableTextAreaShouldClear() {

@Test
@Ignore(value = CHROME, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
@Ignore(value = EDGE, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
void testTextAreaShouldNotClearWhenDisabled() {
driver.get(pages.readOnlyPage);
WebElement element = driver.findElement(By.id("textAreaNotEnabled"));
Expand Down
17 changes: 17 additions & 0 deletions java/test/org/openqa/selenium/ElementFindingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.openqa.selenium.testing.drivers.Browser.CHROME;
import static org.openqa.selenium.testing.drivers.Browser.EDGE;
import static org.openqa.selenium.testing.drivers.Browser.FIREFOX;
import static org.openqa.selenium.testing.drivers.Browser.IE;
import static org.openqa.selenium.testing.drivers.Browser.SAFARI;
Expand Down Expand Up @@ -100,6 +101,7 @@ void testShouldNotBeAbleToLocateByIdMultipleElementsThatDoNotExist() {

@Test
@Ignore(value = CHROME, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
@Ignore(value = EDGE, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
void testFindingASingleElementByEmptyIdShouldThrow() {
driver.get(pages.formPage);
assertThatExceptionOfType(InvalidSelectorException.class)
Expand All @@ -108,6 +110,7 @@ void testFindingASingleElementByEmptyIdShouldThrow() {

@Test
@Ignore(value = CHROME, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
@Ignore(value = EDGE, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
public void testFindingMultipleElementsByEmptyIdShouldThrow() {
driver.get(pages.formPage);
assertThatExceptionOfType(InvalidSelectorException.class)
Expand Down Expand Up @@ -318,6 +321,7 @@ void testShouldNotFindElementByClassWhenTheNameQueriedIsShorterThanCandidateName

@Test
@Ignore(value = CHROME, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
@Ignore(value = EDGE, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
void testFindingASingleElementByEmptyClassNameShouldThrow() {
driver.get(pages.xhtmlTestPage);
assertThatExceptionOfType(InvalidSelectorException.class)
Expand All @@ -326,6 +330,7 @@ void testFindingASingleElementByEmptyClassNameShouldThrow() {

@Test
@Ignore(value = CHROME, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
@Ignore(value = EDGE, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
void testFindingMultipleElementsByEmptyClassNameShouldThrow() {
driver.get(pages.xhtmlTestPage);
assertThatExceptionOfType(InvalidSelectorException.class)
Expand Down Expand Up @@ -439,6 +444,7 @@ void testShouldThrowAnExceptionWhenThereIsNoLinkToClick() {

@Test
@Ignore(value = CHROME, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
@Ignore(value = EDGE, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
void testShouldThrowInvalidSelectorExceptionWhenXPathIsSyntacticallyInvalidInDriverFindElement() {
driver.get(pages.formPage);
assertThatExceptionOfType(InvalidSelectorException.class)
Expand All @@ -447,6 +453,7 @@ void testShouldThrowInvalidSelectorExceptionWhenXPathIsSyntacticallyInvalidInDri

@Test
@Ignore(value = CHROME, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
@Ignore(value = EDGE, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
void
testShouldThrowInvalidSelectorExceptionWhenXPathIsSyntacticallyInvalidInDriverFindElements() {
driver.get(pages.formPage);
Expand All @@ -456,6 +463,7 @@ void testShouldThrowInvalidSelectorExceptionWhenXPathIsSyntacticallyInvalidInDri

@Test
@Ignore(value = CHROME, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
@Ignore(value = EDGE, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
void
testShouldThrowInvalidSelectorExceptionWhenXPathIsSyntacticallyInvalidInElementFindElement() {
driver.get(pages.formPage);
Expand All @@ -466,6 +474,7 @@ void testShouldThrowInvalidSelectorExceptionWhenXPathIsSyntacticallyInvalidInDri

@Test
@Ignore(value = CHROME, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
@Ignore(value = EDGE, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
void
testShouldThrowInvalidSelectorExceptionWhenXPathIsSyntacticallyInvalidInElementFindElements() {
driver.get(pages.formPage);
Expand All @@ -476,6 +485,7 @@ void testShouldThrowInvalidSelectorExceptionWhenXPathIsSyntacticallyInvalidInDri

@Test
@Ignore(value = CHROME, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
@Ignore(value = EDGE, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
void testShouldThrowInvalidSelectorExceptionWhenXPathReturnsWrongTypeInDriverFindElement() {
driver.get(pages.formPage);
assertThatExceptionOfType(InvalidSelectorException.class)
Expand All @@ -484,6 +494,7 @@ void testShouldThrowInvalidSelectorExceptionWhenXPathReturnsWrongTypeInDriverFin

@Test
@Ignore(value = CHROME, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
@Ignore(value = EDGE, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
void testShouldThrowInvalidSelectorExceptionWhenXPathReturnsWrongTypeInDriverFindElements() {
driver.get(pages.formPage);
assertThatExceptionOfType(InvalidSelectorException.class)
Expand All @@ -492,6 +503,7 @@ void testShouldThrowInvalidSelectorExceptionWhenXPathReturnsWrongTypeInDriverFin

@Test
@Ignore(value = CHROME, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
@Ignore(value = EDGE, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
void testShouldThrowInvalidSelectorExceptionWhenXPathReturnsWrongTypeInElementFindElement() {
driver.get(pages.formPage);

Expand All @@ -502,6 +514,7 @@ void testShouldThrowInvalidSelectorExceptionWhenXPathReturnsWrongTypeInElementFi

@Test
@Ignore(value = CHROME, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
@Ignore(value = EDGE, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
void testShouldThrowInvalidSelectorExceptionWhenXPathReturnsWrongTypeInElementFindElements() {
driver.get(pages.formPage);
WebElement body = driver.findElement(By.tagName("body"));
Expand Down Expand Up @@ -582,6 +595,7 @@ void testShouldNotFindElementsByCssSelectorWhenThereIsNoSuchElement() {

@Test
@Ignore(value = CHROME, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
@Ignore(value = EDGE, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
void testFindingASingleElementByEmptyCssSelectorShouldThrow() {
driver.get(pages.xhtmlTestPage);
assertThatExceptionOfType(InvalidSelectorException.class)
Expand All @@ -590,6 +604,7 @@ void testFindingASingleElementByEmptyCssSelectorShouldThrow() {

@Test
@Ignore(value = CHROME, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
@Ignore(value = EDGE, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
void testFindingMultipleElementsByEmptyCssSelectorShouldThrow() {
driver.get(pages.xhtmlTestPage);
assertThatExceptionOfType(InvalidSelectorException.class)
Expand All @@ -598,6 +613,7 @@ void testFindingMultipleElementsByEmptyCssSelectorShouldThrow() {

@Test
@Ignore(value = CHROME, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
@Ignore(value = EDGE, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
void testFindingASingleElementByInvalidCssSelectorShouldThrow() {
driver.get(pages.xhtmlTestPage);
assertThatExceptionOfType(InvalidSelectorException.class)
Expand All @@ -606,6 +622,7 @@ void testFindingASingleElementByInvalidCssSelectorShouldThrow() {

@Test
@Ignore(value = CHROME, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
@Ignore(value = EDGE, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")
void testFindingMultipleElementsByInvalidCssSelectorShouldThrow() {
driver.get(pages.xhtmlTestPage);
assertThatExceptionOfType(InvalidSelectorException.class)
Expand Down
26 changes: 26 additions & 0 deletions javascript/node/selenium-webdriver/bidi/addInterceptParameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ class AddInterceptParameters {
}
}

/**
* Adds a URL pattern to intercept.
*
* @param {UrlPattern} pattern - The URL pattern to add.
* @returns {AddInterceptParameters} - Returns the current instance of the class AddInterceptParameters for chaining.
* @throws {Error} - Throws an error if the pattern is not an instance of UrlPattern.
*/
urlPattern(pattern) {
if (!(pattern instanceof UrlPattern)) {
throw new Error(`Pattern must be an instance of UrlPattern. Received: '${pattern})'`)
Expand All @@ -37,6 +44,13 @@ class AddInterceptParameters {
return this
}

/**
* Adds array of URL patterns to intercept.
*
* @param {UrlPattern[]} patterns - An array of UrlPattern instances representing the URL patterns to intercept.
* @returns {AddInterceptParameters} - Returns the instance of AddInterceptParameters for chaining.
* @throws {Error} - Throws an error if the pattern is not an instance of UrlPattern.
*/
urlPatterns(patterns) {
patterns.forEach((pattern) => {
if (!(pattern instanceof UrlPattern)) {
Expand All @@ -47,6 +61,13 @@ class AddInterceptParameters {
return this
}

/**
* Adds string URL to intercept.
*
* @param {string} pattern - The URL pattern to be added.
* @returns {AddInterceptParameters} - Returns the instance of AddInterceptParameters for chaining..
* @throws {Error} - If the pattern is not an instance of String.
*/
urlStringPattern(pattern) {
if (!(pattern instanceof String)) {
throw new Error(`Pattern must be an instance of String. Received:'${pattern}'`)
Expand All @@ -56,6 +77,11 @@ class AddInterceptParameters {
return this
}

/**
* Adds array of string URLs to intercept.
* @param {string[]} patterns - An array of URL string patterns.
* @returns {this} - Returns the instance of AddInterceptParameters for chaining.
*/
urlStringPatterns(patterns) {
patterns.forEach((pattern) => {
if (!(pattern instanceof String)) {
Expand Down
17 changes: 17 additions & 0 deletions javascript/node/selenium-webdriver/bidi/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
// specific language governing permissions and limitations
// under the License.

/**
* Represents the commands and events under Browser Module.
* Described in https://w3c.github.io/webdriver-bidi/#module-browser
*/
class Browser {
constructor(driver) {
this._driver = driver
Expand All @@ -28,6 +32,10 @@ class Browser {
this.bidi = await this._driver.getBidi()
}

/**
* Creates a new user context.
* @returns {Promise<string>} A promise that resolves to the user context id.
*/
async createUserContext() {
const command = {
method: 'browser.createUserContext',
Expand All @@ -39,6 +47,10 @@ class Browser {
return response.result.userContext
}

/**
* Gets the list of all user contexts.
* @returns {Promise<string[]>} A promise that resolves to an array of user context ids.
*/
async getUserContexts() {
const command = {
method: 'browser.getUserContexts',
Expand All @@ -58,6 +70,11 @@ class Browser {
return userContexts
}

/**
* Removes a user context.
* @param {string} userContext The user context id to be removed.
* @returns {Promise<void>}
*/
async removeUserContext(userContext) {
const command = {
method: 'browser.removeUserContext',
Expand Down
Loading

0 comments on commit dbcf179

Please sign in to comment.