Skip to content

Commit

Permalink
Merge branch 'trunk' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
VietND96 authored Sep 30, 2024
2 parents 6549fcb + 2db9a37 commit a3024b7
Show file tree
Hide file tree
Showing 24 changed files with 331 additions and 328 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
deploy:
if: contains(toJson(github.event.commits), '[deploy site]') == true
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Checkout repo
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/label-commenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ permissions:

jobs:
comment:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Label Commenter
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
test_build:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Checkout repo
uses: actions/checkout@v4
Expand Down
69 changes: 67 additions & 2 deletions examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,74 @@
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.


using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System.Collections.Generic;

namespace SeleniumDocs.Interactions
{
[TestClass]
public class FramesTest : BaseTest
[TestClass]
public class FramesTest
{
[TestMethod]
public void TestFrames()
{
WebDriver driver = new ChromeDriver();
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500);

// Navigate to Url
driver.Url= "https://www.selenium.dev/selenium/web/iframes.html";
//switch To IFrame using Web Element
IWebElement iframe = driver.FindElement(By.Id("iframe1"));
//Switch to the frame
driver.SwitchTo().Frame(iframe);
Assert.AreEqual(true, driver.PageSource.Contains("We Leave From Here"));
//Now we can type text into email field
IWebElement emailE = driver.FindElement(By.Id("email"));
emailE.SendKeys("[email protected]");
emailE.Clear();
driver.SwitchTo().DefaultContent();


//switch To IFrame using name or id
driver.FindElement(By.Name("iframe1-name"));
//Switch to the frame
driver.SwitchTo().Frame(iframe);
Assert.AreEqual(true, driver.PageSource.Contains("We Leave From Here"));
IWebElement email = driver.FindElement(By.Id("email"));
//Now we can type text into email field
email.SendKeys("[email protected]");
email.Clear();
driver.SwitchTo().DefaultContent();


//switch To IFrame using index
driver.SwitchTo().Frame(0);
Assert.AreEqual(true, driver.PageSource.Contains("We Leave From Here"));

//leave frame
driver.SwitchTo().DefaultContent();
Assert.AreEqual(true, driver.PageSource.Contains("This page has iframes"));

//quit the browser
driver.Quit();
}
}
}
48 changes: 48 additions & 0 deletions examples/dotnet/SeleniumDocs/Interactions/InteractionsTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.


using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace SeleniumDocumentation.SeleniumInteractions
{
[TestClass]
public class InteractionsTest
{
[TestMethod]
public void TestInteractions()
{
WebDriver driver = new ChromeDriver();
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500);

// Navigate to Url
driver.Url="https://www.selenium.dev/";
//GetTitle
String title = driver.Title;
Assert.AreEqual(title, "Selenium");

//GetCurrentURL
String url = driver.Url;
Assert.AreEqual(url, "https://www.selenium.dev/");

//quitting driver
driver.Quit(); //close all windows
}
}
}
2 changes: 1 addition & 1 deletion examples/java/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,92 @@
package dev.selenium.interactions;
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import dev.selenium.BaseTest;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class AlertsTest extends BaseTest {
import java.time.Duration;

}
import static org.junit.jupiter.api.Assertions.assertEquals;

public class AlertsTest {

@Test
public void testForAlerts() throws Exception {

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("disable-search-engine-choice-screen");
WebDriver driver = new ChromeDriver(chromeOptions);

driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
driver.manage().window().maximize();
//Navigate to Url
driver.get("https://www.selenium.dev/documentation/webdriver/interactions/alerts/");

//Simple Alert
//Click the link to activate the alert
JavascriptExecutor js = (JavascriptExecutor) driver;
//execute js for alert
js.executeScript("alert('Sample Alert');");
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(30));
//Wait for the alert to be displayed and store it in a variable
wait.until(ExpectedConditions.alertIsPresent());

Alert alert = driver.switchTo().alert();
//Store the alert text in a variable and verify it
String text = alert.getText();
assertEquals(text, "Sample Alert");
//Press the OK button
alert.accept();

//Confirm
//execute js for confirm
js.executeScript("confirm('Are you sure?');");
//Wait for the alert to be displayed
wait = new WebDriverWait(driver, Duration.ofSeconds(30));
wait.until(ExpectedConditions.alertIsPresent());


alert = driver.switchTo().alert();
//Store the alert text in a variable and verify it
text = alert.getText();
assertEquals(text, "Are you sure?");
//Press the Cancel button
alert.dismiss();

//Prompt
//execute js for prompt
js.executeScript("prompt('What is your name?');");
//Wait for the alert to be displayed and store it in a variable
wait = new WebDriverWait(driver, Duration.ofSeconds(30));
wait.until(ExpectedConditions.alertIsPresent());

alert = driver.switchTo().alert();
//Store the alert text in a variable and verify it
text = alert.getText();
assertEquals(text, "What is your name?");
//Type your message
alert.sendKeys("Selenium");
//Press the OK button
alert.accept();
//quit the browser
driver.quit();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ In order to use WebDriver BiDi, setting the capability in the browser options wi

{{< tabpane langEqualsHeader=true >}}
{{< tab header="Java" >}}
options.setCapability("webSocketUrl", true);
options.setCapability("webSocketUrl", true);
{{< /tab >}}
{{% tab header="Python" text=true %}}
{{< badge-code >}}
{{< tab header="Python" >}}
options.enable_bidi = True
{{% /tab %}}
{{< tab header="CSharp" >}}
UseWebSocketUrl = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ You can read the current page title from the browser:
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_interactions.py#L7" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}driver.Title;{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/InteractionsTest.cs#L37" >}}
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/browser_spec.rb#L8" >}}
{{< /tab >}}
Expand All @@ -46,7 +48,9 @@ You can read the current URL from the browser's address bar using:
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_interactions.py#L10" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}driver.Url;{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/InteractionsTest.cs#L41" >}}
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/browser_spec.rb#L14" >}}
{{< /tab >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ aliases: [
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_interactions.py#L7" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}driver.Title;{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/InteractionsTest.cs#L37" >}}
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/browser_spec.rb#L8" >}}
{{< /tab >}}
Expand All @@ -44,7 +46,9 @@ aliases: [
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_interactions.py#L10" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}driver.Url;{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/InteractionsTest.cs#L41" >}}
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/browser_spec.rb#L14" >}}
{{< /tab >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ Você pode ler o título da página atual no navegador:
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_interactions.py#L7" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}driver.Title;{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/InteractionsTest.cs#L37" >}}
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/browser_spec.rb#L8" >}}
{{< /tab >}}
Expand All @@ -45,7 +47,9 @@ Você pode ler a URL atual na barra de endereço do navegador usando:
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_interactions.py#L10" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}driver.Url;{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/InteractionsTest.cs#L41" >}}
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/browser_spec.rb#L14" >}}
{{< /tab >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ aliases: [
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_interactions.py#L7" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}driver.Title;{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/InteractionsTest.cs#L37" >}}
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/browser_spec.rb#L8" >}}
{{< /tab >}}
Expand All @@ -43,7 +45,9 @@ aliases: [
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_interactions.py#L10" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}driver.Url;{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/InteractionsTest.cs#L41" >}}
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/browser_spec.rb#L14" >}}
{{< /tab >}}
Expand Down
Loading

0 comments on commit a3024b7

Please sign in to comment.