From 37d1818bb24de548b0ec939f7ad7c87a78b778d7 Mon Sep 17 00:00:00 2001 From: Viet Nguyen Duc Date: Mon, 4 Nov 2024 23:17:46 +0700 Subject: [PATCH 1/3] Add examples for http_client java and python Signed-off-by: Viet Nguyen Duc --- .github/workflows/java-examples.yml | 19 ++-- .github/workflows/python-examples.yml | 2 +- .gitignore | 2 + .../src/test/java/dev/selenium/BaseTest.java | 36 +++++++ .../dev/selenium/drivers/HttpClientTest.java | 98 ++++++++++++++++++ examples/java/src/test/resources/server.jks | Bin 0 -> 2896 bytes examples/java/src/test/resources/tls.crt | 24 +++++ examples/java/src/test/resources/tls.key | 28 +++++ examples/python/requirements.txt | 1 + examples/python/tests/conftest.py | 87 ++++++++++++++++ .../python/tests/drivers/test_http_client.py | 46 ++++++++ examples/python/tests/resources/server.jks | Bin 0 -> 2896 bytes examples/python/tests/resources/tls.crt | 24 +++++ examples/python/tests/resources/tls.key | 28 +++++ .../webdriver/drivers/http_client.en.md | 4 +- 15 files changed, 390 insertions(+), 9 deletions(-) create mode 100644 examples/java/src/test/resources/server.jks create mode 100644 examples/java/src/test/resources/tls.crt create mode 100644 examples/java/src/test/resources/tls.key create mode 100644 examples/python/tests/resources/server.jks create mode 100644 examples/python/tests/resources/tls.crt create mode 100644 examples/python/tests/resources/tls.key diff --git a/.github/workflows/java-examples.yml b/.github/workflows/java-examples.yml index a13dee1e3510..339ef92f930f 100644 --- a/.github/workflows/java-examples.yml +++ b/.github/workflows/java-examples.yml @@ -45,24 +45,31 @@ jobs: if: matrix.os == 'ubuntu' run: Xvfb :99 & - name: Set up Java + id: java uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: 17 + - name: Import test cert non-Windows + if: matrix.os != 'windows' + run: sudo keytool -import -noprompt -trustcacerts -alias SeleniumHQ -file examples/java/src/test/resources/tls.crt -keystore ${{ steps.java.outputs.path }}/lib/security/cacerts -storepass changeit + - name: Import test cert Windows + if: matrix.os == 'windows' + run: keytool -import -noprompt -trustcacerts -alias SeleniumHQ -file examples/java/src/test/resources/tls.crt -keystore ${{ steps.java.outputs.path }}/lib/security/cacerts -storepass changeit - name: Run Tests Stable if: matrix.release == 'stable' uses: nick-invision/retry@v3.0.0 with: - timeout_minutes: 20 + timeout_minutes: 40 max_attempts: 3 command: | cd examples/java - mvn -B test + mvn -B test -D"jdk.internal.httpclient.disableHostnameVerification=true" - name: Run Tests Nightly Linux/macOS if: matrix.release == 'nightly' && matrix.os != 'windows' uses: nick-invision/retry@v3.0.0 with: - timeout_minutes: 20 + timeout_minutes: 40 max_attempts: 3 command: | pip install yq @@ -70,13 +77,13 @@ jobs: latest_snapshot=$(echo "$xml_content" | xq '.content.data."content-item"' | jq -r 'sort_by(.lastModified) | last | .text') echo "Latest Selenium Snapshot: $latest_snapshot" cd examples/java - mvn -B -U test -Dselenium.version="$latest_snapshot" + mvn -B -U test -D"jdk.internal.httpclient.disableHostnameVerification=true" - name: Run Tests Nightly Windows if: matrix.release == 'nightly' && matrix.os == 'windows' uses: nick-invision/retry@v3.0.0 with: - timeout_minutes: 20 + timeout_minutes: 40 max_attempts: 3 command: | pip install yq @@ -84,4 +91,4 @@ jobs: $latest_snapshot = $xml_content.Content | xq '.content.data.\"content-item\"' | jq -r 'sort_by(.lastModified) | last | .text' Write-Output "Latest Selenium Snapshot: $latest_snapshot" cd examples/java - mvn -B -U test "-Dselenium.version=$latest_snapshot" + mvn -B -U test -D"jdk.internal.httpclient.disableHostnameVerification=true" diff --git a/.github/workflows/python-examples.yml b/.github/workflows/python-examples.yml index 5e175840e41e..e7d432cab113 100644 --- a/.github/workflows/python-examples.yml +++ b/.github/workflows/python-examples.yml @@ -80,7 +80,7 @@ jobs: - name: Run tests uses: nick-invision/retry@v3.0.0 with: - timeout_minutes: 20 + timeout_minutes: 40 max_attempts: 3 command: | cd examples/python diff --git a/.gitignore b/.gitignore index 43ede48a62fd..c828c5469d5d 100755 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ website_and_docs/resources .settings .gitignore .pydevproject +**/*.iml +**/.gradle diff --git a/examples/java/src/test/java/dev/selenium/BaseTest.java b/examples/java/src/test/java/dev/selenium/BaseTest.java index 63ad5759d0e8..b12214c5a71b 100644 --- a/examples/java/src/test/java/dev/selenium/BaseTest.java +++ b/examples/java/src/test/java/dev/selenium/BaseTest.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.net.URL; import java.nio.file.Files; +import java.nio.file.Path; import java.time.Duration; import java.util.Arrays; import java.util.logging.Level; @@ -26,6 +27,9 @@ public class BaseTest { protected WebDriverWait wait; protected File driverPath; protected File browserPath; + protected String username = "admin"; + protected String password = "myStrongPassword"; + protected String trustStorePassword = "seleniumkeystore"; public WebElement getLocatedElement(WebDriver driver, By by) { WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5)); @@ -98,6 +102,38 @@ protected URL startStandaloneGrid() { } } + protected URL startStandaloneGridAdvanced() { + int port = PortProber.findFreePort(); + try { + System.setProperty("javax.net.ssl.trustStore", Path.of("src/test/resources/server.jks").toAbsolutePath().toString()); + System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword); + System.setProperty("jdk.internal.httpclient.disableHostnameVerification", "true"); + Main.main( + new String[] { + "standalone", + "--port", + String.valueOf(port), + "--selenium-manager", + "true", + "--enable-managed-downloads", + "true", + "--log-level", + "WARNING", + "--username", + username, + "--password", + password, + "--https-certificate", + Path.of("src/test/resources/tls.crt").toAbsolutePath().toString(), + "--https-private-key", + Path.of("src/test/resources/tls.key").toAbsolutePath().toString() + }); + return new URL("https://localhost:" + port); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + protected void enableLogging() { Logger logger = Logger.getLogger(""); logger.setLevel(Level.FINE); diff --git a/examples/java/src/test/java/dev/selenium/drivers/HttpClientTest.java b/examples/java/src/test/java/dev/selenium/drivers/HttpClientTest.java index 2bf0923f6cbb..8304dba81dd6 100644 --- a/examples/java/src/test/java/dev/selenium/drivers/HttpClientTest.java +++ b/examples/java/src/test/java/dev/selenium/drivers/HttpClientTest.java @@ -2,6 +2,104 @@ import dev.selenium.BaseTest; +import org.openqa.selenium.remote.http.ClientConfig; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.chrome.ChromeOptions; +import org.openqa.selenium.remote.RemoteWebDriver; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; +import java.io.FileInputStream; +import java.net.URL; +import java.nio.file.Path; +import java.security.KeyStore; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.time.Duration; + +import org.openqa.selenium.UsernameAndPassword; + +import static java.net.http.HttpClient.Version.HTTP_1_1; + public class HttpClientTest extends BaseTest { + URL gridUrl; + + @BeforeEach + public void startGrid() { + gridUrl = startStandaloneGridAdvanced(); + } + + @Test + public void remoteWebDriverWithClientConfig() throws Exception { + ClientConfig clientConfig = ClientConfig.defaultConfig() + .withRetries() + .sslContext(createSSLContextWithCA(Path.of("src/test/resources/tls.crt").toAbsolutePath().toString())) + .connectionTimeout(Duration.ofSeconds(300)) + .readTimeout(Duration.ofSeconds(3600)) + .authenticateAs(new UsernameAndPassword("admin", "myStrongPassword")) + .version(HTTP_1_1.toString()); + ChromeOptions options = new ChromeOptions(); + options.setEnableDownloads(true); + driver = RemoteWebDriver.builder() + .oneOf(options) + .address(gridUrl) + .config(clientConfig) + .build(); + driver.quit(); + } + + @Test + public void remoteWebDriverIgnoreSSL() throws Exception { + ClientConfig clientConfig = ClientConfig.defaultConfig() + .withRetries() + .sslContext(createIgnoreSSLContext()) + .connectionTimeout(Duration.ofSeconds(300)) + .readTimeout(Duration.ofSeconds(3600)) + .authenticateAs(new UsernameAndPassword("admin", "myStrongPassword")) + .version(HTTP_1_1.toString()); + ChromeOptions options = new ChromeOptions(); + options.setEnableDownloads(true); + driver = RemoteWebDriver.builder() + .oneOf(options) + .address(gridUrl) + .config(clientConfig) + .build(); + driver.quit(); + } + + public static SSLContext createSSLContextWithCA(String caCertPath) throws Exception { + FileInputStream fis = new FileInputStream(caCertPath); + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + X509Certificate caCert = (X509Certificate) cf.generateCertificate(fis); + KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); + keyStore.load(null, null); + keyStore.setCertificateEntry("caCert", caCert); + TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + tmf.init(keyStore); + SSLContext sslContext = SSLContext.getInstance("TLS"); + sslContext.init(null, tmf.getTrustManagers(), null); + return sslContext; + } + + public static SSLContext createIgnoreSSLContext() throws Exception { + TrustManager[] trustAllCerts = new TrustManager[]{ + new X509TrustManager() { + public X509Certificate[] getAcceptedIssuers() { + return null; + } + + public void checkClientTrusted(X509Certificate[] certs, String authType) { + } + public void checkServerTrusted(X509Certificate[] certs, String authType) { + } + } + }; + SSLContext sslContext = SSLContext.getInstance("TLS"); + sslContext.init(null, trustAllCerts, new java.security.SecureRandom()); + return sslContext; + } } diff --git a/examples/java/src/test/resources/server.jks b/examples/java/src/test/resources/server.jks new file mode 100644 index 0000000000000000000000000000000000000000..76579e1776c1815faa2052dd1ff0089c29c96284 GIT binary patch literal 2896 zcma);X*d*)7RG0$8DlVo>=Yqn9Xn&E>>*1`d*1ha{5=OjWVHkVPauda+e|QNk|}8i4uk@8 zh%Ad>BFpTtJcS@aDF3yB6oQG6ykj~0xH6bn|C3^40fKUf5dC9O8{zRM0f8eN5gLDw zYzP@JmjsDM;bx8vhz~^dn#UuD`m28kfjfwf+7eO!x0C9#1h9;Q;-A{ml z(qQ(p?9?j+JnUZM^_Xa6hAs?D1P^Sr7P<_!jkY4FFm(8{zU%FYXtW&vTeowrK(*Sv z<;@e-a%J7B+^)?pXeb|r5sO;YOlHL+@p$UV)h91%mHI!Jsa$BVY$#4PN-5sVv;`dQ zU`2Jp4J_q5^uibUq4Vw1cGu!x$vwtET%oOp1Ju%TBfTq#4-)D|DN9(mvJIE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@ub(y~=DJT0ko^wQcPV(uSiPI@PbSw`p}} {{< tab header="Java" >}} -{{< badge-code >}} +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/drivers/HttpClientTest.java" >}} {{< /tab >}} {{% tab header="Python" %}} -{{< badge-code >}} +{{< gh-codeblock path="examples/python/tests/drivers/test_http_client.py" >}} {{% /tab %}} {{< tab header="CSharp" >}} {{< badge-code >}} From 00151b43733984863fa45a1286a5b5ce65a00888 Mon Sep 17 00:00:00 2001 From: Viet Nguyen Duc Date: Tue, 5 Nov 2024 13:54:29 +0700 Subject: [PATCH 2/3] Updated for other languages Signed-off-by: Viet Nguyen Duc --- .../content/documentation/webdriver/drivers/http_client.ja.md | 4 ++-- .../documentation/webdriver/drivers/http_client.pt-br.md | 4 ++-- .../documentation/webdriver/drivers/http_client.zh-cn.md | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/website_and_docs/content/documentation/webdriver/drivers/http_client.ja.md b/website_and_docs/content/documentation/webdriver/drivers/http_client.ja.md index 165e79efa0bc..436a4a52d283 100644 --- a/website_and_docs/content/documentation/webdriver/drivers/http_client.ja.md +++ b/website_and_docs/content/documentation/webdriver/drivers/http_client.ja.md @@ -8,10 +8,10 @@ weight: 3 {{< tabpane text=true >}} {{< tab header="Java" >}} -{{< badge-code >}} +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/drivers/HttpClientTest.java" >}} {{< /tab >}} {{% tab header="Python" %}} -{{< badge-code >}} +{{< gh-codeblock path="examples/python/tests/drivers/test_http_client.py" >}} {{% /tab %}} {{< tab header="CSharp" >}} {{< badge-code >}} diff --git a/website_and_docs/content/documentation/webdriver/drivers/http_client.pt-br.md b/website_and_docs/content/documentation/webdriver/drivers/http_client.pt-br.md index ce95a52a78c9..4f537b6270ef 100644 --- a/website_and_docs/content/documentation/webdriver/drivers/http_client.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/drivers/http_client.pt-br.md @@ -8,10 +8,10 @@ These allow you to set various parameters for the HTTP library {{< tabpane text=true >}} {{< tab header="Java" >}} -{{< badge-code >}} +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/drivers/HttpClientTest.java" >}} {{< /tab >}} {{% tab header="Python" %}} -{{< badge-code >}} +{{< gh-codeblock path="examples/python/tests/drivers/test_http_client.py" >}} {{% /tab %}} {{< tab header="CSharp" >}} {{< badge-code >}} diff --git a/website_and_docs/content/documentation/webdriver/drivers/http_client.zh-cn.md b/website_and_docs/content/documentation/webdriver/drivers/http_client.zh-cn.md index 667574dcb3b3..6f3ba9f8fcd0 100644 --- a/website_and_docs/content/documentation/webdriver/drivers/http_client.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/drivers/http_client.zh-cn.md @@ -8,10 +8,10 @@ weight: 3 {{< tabpane text=true >}} {{< tab header="Java" >}} -{{< badge-code >}} +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/drivers/HttpClientTest.java" >}} {{< /tab >}} {{% tab header="Python" %}} -{{< badge-code >}} +{{< gh-codeblock path="examples/python/tests/drivers/test_http_client.py" >}} {{% /tab %}} {{< tab header="CSharp" >}} {{< badge-code >}} From 707454d680b79b49ff9aff09215f886c992b7c88 Mon Sep 17 00:00:00 2001 From: Viet Nguyen Duc Date: Tue, 5 Nov 2024 13:20:57 +0530 Subject: [PATCH 3/3] Fix flaky test in examples python (#2042) Signed-off-by: Viet Nguyen Duc --- .../python/tests/actions_api/test_mouse.py | 49 +++++++++---------- examples/python/tests/bidi/cdp/test_script.py | 9 ++-- .../webdriver/actions_api/mouse.en.md | 24 ++++----- .../webdriver/actions_api/mouse.ja.md | 24 ++++----- .../webdriver/actions_api/mouse.pt-br.md | 24 ++++----- .../webdriver/actions_api/mouse.zh-cn.md | 24 ++++----- .../webdriver/bidi/cdp/script.en.md | 2 +- .../webdriver/bidi/cdp/script.ja.md | 2 +- .../webdriver/bidi/cdp/script.pt-br.md | 2 +- .../webdriver/bidi/cdp/script.zh-cn.md | 2 +- 10 files changed, 80 insertions(+), 82 deletions(-) diff --git a/examples/python/tests/actions_api/test_mouse.py b/examples/python/tests/actions_api/test_mouse.py index cc114389ccf4..9df04fd599f7 100644 --- a/examples/python/tests/actions_api/test_mouse.py +++ b/examples/python/tests/actions_api/test_mouse.py @@ -1,17 +1,19 @@ +import pytest from time import sleep - from selenium.webdriver import ActionChains from selenium.webdriver.common.actions.action_builder import ActionBuilder from selenium.webdriver.common.actions.mouse_button import MouseButton from selenium.webdriver.common.by import By +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC def test_click_and_hold(driver): driver.get('https://selenium.dev/selenium/web/mouse_interaction.html') clickable = driver.find_element(By.ID, "clickable") - ActionChains(driver)\ - .click_and_hold(clickable)\ + ActionChains(driver) \ + .click_and_hold(clickable) \ .perform() sleep(0.5) @@ -22,8 +24,8 @@ def test_click_and_release(driver): driver.get('https://selenium.dev/selenium/web/mouse_interaction.html') clickable = driver.find_element(By.ID, "click") - ActionChains(driver)\ - .click(clickable)\ + ActionChains(driver) \ + .click(clickable) \ .perform() assert "resultPage.html" in driver.current_url @@ -33,8 +35,8 @@ def test_right_click(driver): driver.get('https://selenium.dev/selenium/web/mouse_interaction.html') clickable = driver.find_element(By.ID, "clickable") - ActionChains(driver)\ - .context_click(clickable)\ + ActionChains(driver) \ + .context_click(clickable) \ .perform() sleep(0.5) @@ -72,8 +74,8 @@ def test_double_click(driver): driver.get('https://selenium.dev/selenium/web/mouse_interaction.html') clickable = driver.find_element(By.ID, "clickable") - ActionChains(driver)\ - .double_click(clickable)\ + ActionChains(driver) \ + .double_click(clickable) \ .perform() assert driver.find_element(By.ID, "click-status").text == "double-clicked" @@ -83,8 +85,8 @@ def test_hover(driver): driver.get('https://selenium.dev/selenium/web/mouse_interaction.html') hoverable = driver.find_element(By.ID, "hover") - ActionChains(driver)\ - .move_to_element(hoverable)\ + ActionChains(driver) \ + .move_to_element(hoverable) \ .perform() assert driver.find_element(By.ID, "move-status").text == "hovered" @@ -94,8 +96,8 @@ def test_move_by_offset_from_element(driver): driver.get('https://selenium.dev/selenium/web/mouse_interaction.html') mouse_tracker = driver.find_element(By.ID, "mouse-tracker") - ActionChains(driver)\ - .move_to_element_with_offset(mouse_tracker, 8, 0)\ + ActionChains(driver) \ + .move_to_element_with_offset(mouse_tracker, 8, 0) \ .perform() coordinates = driver.find_element(By.ID, "relative-location").text.split(", ") @@ -104,7 +106,7 @@ def test_move_by_offset_from_element(driver): def test_move_by_offset_from_viewport_origin_ab(driver): driver.get('https://selenium.dev/selenium/web/mouse_interaction.html') - + WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "absolute-location"))) action = ActionBuilder(driver) action.pointer_action.move_to_location(8, 0) action.perform() @@ -121,8 +123,8 @@ def test_move_by_offset_from_current_pointer_ab(driver): action.pointer_action.move_to_location(6, 3) action.perform() - ActionChains(driver)\ - .move_by_offset( 13, 15)\ + ActionChains(driver) \ + .move_by_offset(13, 15) \ .perform() coordinates = driver.find_element(By.ID, "absolute-location").text.split(", ") @@ -136,8 +138,8 @@ def test_drag_and_drop_onto_element(driver): draggable = driver.find_element(By.ID, "draggable") droppable = driver.find_element(By.ID, "droppable") - ActionChains(driver)\ - .drag_and_drop(draggable, droppable)\ + ActionChains(driver) \ + .drag_and_drop(draggable, droppable) \ .perform() assert driver.find_element(By.ID, "drop-status").text == "dropped" @@ -149,15 +151,8 @@ def test_drag_and_drop_by_offset(driver): draggable = driver.find_element(By.ID, "draggable") start = draggable.location finish = driver.find_element(By.ID, "droppable").location - ActionChains(driver)\ - .drag_and_drop_by_offset(draggable, finish['x'] - start['x'], finish['y'] - start['y'])\ + ActionChains(driver) \ + .drag_and_drop_by_offset(draggable, finish['x'] - start['x'], finish['y'] - start['y']) \ .perform() assert driver.find_element(By.ID, "drop-status").text == "dropped" - - - - - - - diff --git a/examples/python/tests/bidi/cdp/test_script.py b/examples/python/tests/bidi/cdp/test_script.py index c547de1d25da..9c837c75e227 100644 --- a/examples/python/tests/bidi/cdp/test_script.py +++ b/examples/python/tests/bidi/cdp/test_script.py @@ -1,13 +1,16 @@ import pytest +import trio from selenium.webdriver.common.by import By from selenium.webdriver.common.log import Log - +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC @pytest.mark.trio async def test_mutation(driver): async with driver.bidi_connection() as session: async with Log(driver, session).mutation_events() as event: - driver.get('https://www.selenium.dev/selenium/web/dynamic.html') - driver.find_element(By.ID, "reveal").click() + await trio.to_thread.run_sync(lambda: driver.get('https://www.selenium.dev/selenium/web/dynamic.html')) + await trio.to_thread.run_sync(lambda: WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "reveal")))) + await trio.to_thread.run_sync(lambda: driver.find_element(By.ID, "reveal").click()) assert event["element"] == driver.find_element(By.ID, "revealed") diff --git a/website_and_docs/content/documentation/webdriver/actions_api/mouse.en.md b/website_and_docs/content/documentation/webdriver/actions_api/mouse.en.md index 912517abaa43..a8932aaca1b0 100644 --- a/website_and_docs/content/documentation/webdriver/actions_api/mouse.en.md +++ b/website_and_docs/content/documentation/webdriver/actions_api/mouse.en.md @@ -25,7 +25,7 @@ This is useful for focusing a specific element: {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L22-L25" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L12-L15" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L14-L17" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L17-L20" >}} @@ -51,7 +51,7 @@ This is otherwise known as "clicking": {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L34-L37" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L24-L27" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L26-L29" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L30-L33" >}} @@ -86,7 +86,7 @@ This is otherwise known as "right-clicking": {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L46-L49" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L35-L38" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L37-L40" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L43-L46" >}} @@ -112,7 +112,7 @@ There is no convenience method for this, it is just pressing and releasing mouse {{< /tab >}} {{< tab header="Python" >}} {{< badge-version version="4.2" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L49-L52" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L51-L54" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< badge-version version="4.2" >}} @@ -141,7 +141,7 @@ There is no convenience method for this, it is just pressing and releasing mouse {{< /tab >}} {{< tab header="Python" >}} {{< badge-version version="4.2" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L63-L66" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L65-L68" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< badge-version version="4.2" >}} @@ -169,7 +169,7 @@ This method combines moving to the center of an element with pressing and releas {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L93-L96" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L74-L77" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L76-L79" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L91-L94" >}} @@ -196,7 +196,7 @@ Note that the element must be in the viewport or else the command will error. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L105-L108" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L85-L88" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L87-L90" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L104-L107" >}} @@ -228,7 +228,7 @@ then moves by the provided offset. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L118-L121" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L96-L99" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L98-L101" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L132-L135" >}} @@ -254,7 +254,7 @@ offset. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L131-L136" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L108-L110" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L110-L112" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L146-L150" >}} @@ -286,7 +286,7 @@ the current mouse position. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L153-L155" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L124-L126" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L126-L128" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L167-L169" >}} @@ -312,7 +312,7 @@ moves to the location of the target element and then releases the mouse. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L166-L170" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L137-L141" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L139-L143" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L181-L185" >}} @@ -337,7 +337,7 @@ This method firstly performs a click-and-hold on the source element, moves to th {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L179-L184" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L149-L154" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L151-L156" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L195-L200" >}} diff --git a/website_and_docs/content/documentation/webdriver/actions_api/mouse.ja.md b/website_and_docs/content/documentation/webdriver/actions_api/mouse.ja.md index 66d25e2d8b75..17b06169391d 100644 --- a/website_and_docs/content/documentation/webdriver/actions_api/mouse.ja.md +++ b/website_and_docs/content/documentation/webdriver/actions_api/mouse.ja.md @@ -25,7 +25,7 @@ This is useful for focusing a specific element: {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L22-L25" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L12-L15" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L14-L17" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L17-L20" >}} @@ -51,7 +51,7 @@ This is otherwise known as "clicking": {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L34-L37" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L24-L27" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L26-L29" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L30-L33" >}} @@ -86,7 +86,7 @@ This is otherwise known as "right-clicking": {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L46-L49" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L35-L38" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L37-L40" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L43-L46" >}} @@ -112,7 +112,7 @@ There is no convenience method for this, it is just pressing and releasing mouse {{< /tab >}} {{< tab header="Python" >}} {{< badge-version version="4.2" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L49-L52" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L51-L54" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< badge-version version="4.2" >}} @@ -141,7 +141,7 @@ There is no convenience method for this, it is just pressing and releasing mouse {{< /tab >}} {{< tab header="Python" >}} {{< badge-version version="4.2" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L63-L66" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L65-L68" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< badge-version version="4.2" >}} @@ -169,7 +169,7 @@ This method combines moving to the center of an element with pressing and releas {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L93-L96" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L74-L77" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L76-L79" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L91-L94" >}} @@ -196,7 +196,7 @@ Note that the element must be in the viewport or else the command will error. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L105-L108" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L85-L88" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L87-L90" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L104-L107" >}} @@ -228,7 +228,7 @@ then moves by the provided offset. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L118-L121" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L96-L99" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L98-L101" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L132-L135" >}} @@ -254,7 +254,7 @@ offset. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L131-L136" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L108-L110" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L110-L112" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L146-L150" >}} @@ -286,7 +286,7 @@ the current mouse position. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L153-L155" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L124-L126" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L126-L128" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L167-L169" >}} @@ -312,7 +312,7 @@ moves to the location of the target element and then releases the mouse. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L166-L170" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L137-L141" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L139-L143" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L181-L185" >}} @@ -337,7 +337,7 @@ This method firstly performs a click-and-hold on the source element, moves to th {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L179-L184" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L149-L154" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L151-L156" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L195-L200" >}} diff --git a/website_and_docs/content/documentation/webdriver/actions_api/mouse.pt-br.md b/website_and_docs/content/documentation/webdriver/actions_api/mouse.pt-br.md index db6cc0c4d992..3faf08d59150 100644 --- a/website_and_docs/content/documentation/webdriver/actions_api/mouse.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/actions_api/mouse.pt-br.md @@ -22,7 +22,7 @@ Este método combina mover o mouse para o centro de um elemento com a pressão d {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L22-L25" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L12-L15" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L14-L17" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L17-L20" >}} @@ -47,7 +47,7 @@ Este método combina mover o mouse para o centro de um elemento com a pressão e {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L34-L37" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L24-L27" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L26-L29" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L30-L33" >}} @@ -82,7 +82,7 @@ Este método combina mover o mouse para o centro de um elemento com a pressão e {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L46-L49" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L35-L38" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L37-L40" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L43-L46" >}} @@ -108,7 +108,7 @@ Este termo pode se referir a um clique com o botão X1 (botão de voltar) do mou {{< /tab >}} {{< tab header="Python" >}} {{< badge-version version="4.2" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L49-L52" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L51-L54" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< badge-version version="4.2" >}} @@ -137,7 +137,7 @@ Este termo se refere a um clique com o botão X2 (botão de avançar) do mouse. {{< /tab >}} {{< tab header="Python" >}} {{< badge-version version="4.2" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L63-L66" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L65-L68" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< badge-version version="4.2" >}} @@ -165,7 +165,7 @@ Este método combina mover o mouse para o centro de um elemento com a pressão e {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L93-L96" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L74-L77" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L76-L79" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L91-L94" >}} @@ -190,7 +190,7 @@ Este método move o mouse para o ponto central do elemento que está visível na {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L105-L108" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L85-L88" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L87-L90" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L104-L107" >}} @@ -219,7 +219,7 @@ Este método move o mouse para o ponto central do elemento visível na tela e, e {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L118-L121" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L96-L99" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L98-L101" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L132-L135" >}} @@ -244,7 +244,7 @@ Este método move o mouse a partir do canto superior esquerdo da janela de visua {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L131-L136" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L108-L110" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L110-L112" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L146-L150" >}} @@ -270,7 +270,7 @@ Observe que o primeiro argumento, X, especifica o movimento para a direita quand {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L153-L155" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L124-L126" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L126-L128" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L167-L169" >}} @@ -295,7 +295,7 @@ Este método primeiro realiza um clique e mantém pressionado no elemento de ori {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L166-L170" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L137-L141" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L139-L143" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L181-L185" >}} @@ -320,7 +320,7 @@ Este método primeiro realiza um clique e mantém pressionado no elemento de ori {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L179-L184" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L149-L154" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L151-L156" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L195-L200" >}} diff --git a/website_and_docs/content/documentation/webdriver/actions_api/mouse.zh-cn.md b/website_and_docs/content/documentation/webdriver/actions_api/mouse.zh-cn.md index aaf255bd7814..63748d0a108f 100644 --- a/website_and_docs/content/documentation/webdriver/actions_api/mouse.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/actions_api/mouse.zh-cn.md @@ -26,7 +26,7 @@ Selenium组合了常见的操作并提供了方便的方法。 {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L22-L25" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L12-L15" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L14-L17" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L17-L20" >}} @@ -52,7 +52,7 @@ Selenium组合了常见的操作并提供了方便的方法。 {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L34-L37" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L24-L27" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L26-L29" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L30-L33" >}} @@ -87,7 +87,7 @@ Selenium组合了常见的操作并提供了方便的方法。 {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L46-L49" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L35-L38" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L37-L40" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L43-L46" >}} @@ -113,7 +113,7 @@ Selenium组合了常见的操作并提供了方便的方法。 {{< /tab >}} {{< tab header="Python" >}} {{< badge-version version="4.2" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L49-L52" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L51-L54" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< badge-version version="4.2" >}} @@ -142,7 +142,7 @@ Selenium组合了常见的操作并提供了方便的方法。 {{< /tab >}} {{< tab header="Python" >}} {{< badge-version version="4.2" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L63-L66" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L65-L68" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< badge-version version="4.2" >}} @@ -170,7 +170,7 @@ Selenium组合了常见的操作并提供了方便的方法。 {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L93-L96" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L74-L77" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L76-L79" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L91-L94" >}} @@ -197,7 +197,7 @@ Selenium组合了常见的操作并提供了方便的方法。 {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L105-L108" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L85-L88" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L87-L90" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L104-L107" >}} @@ -227,7 +227,7 @@ Selenium组合了常见的操作并提供了方便的方法。 {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L118-L121" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L96-L99" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L98-L101" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L132-L135" >}} @@ -252,7 +252,7 @@ Selenium组合了常见的操作并提供了方便的方法。 {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L131-L136" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L108-L110" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L110-L112" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L146-L150" >}} @@ -281,7 +281,7 @@ Selenium组合了常见的操作并提供了方便的方法。 {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L153-L155" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L124-L126" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L126-L128" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L167-L169" >}} @@ -306,7 +306,7 @@ Selenium组合了常见的操作并提供了方便的方法。 {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L166-L170" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L137-L141" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L139-L143" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L181-L185" >}} @@ -330,7 +330,7 @@ Selenium组合了常见的操作并提供了方便的方法。 {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/actions_api/MouseTest.java#L179-L184" >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L149-L154" >}} +{{< gh-codeblock path="/examples/python/tests/actions_api/test_mouse.py#L151-L156" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs#L195-L200" >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/cdp/script.en.md b/website_and_docs/content/documentation/webdriver/bidi/cdp/script.en.md index 6b82792f71df..b5ffc08db88b 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/cdp/script.en.md +++ b/website_and_docs/content/documentation/webdriver/bidi/cdp/script.en.md @@ -42,7 +42,7 @@ methods will eventually be removed when WebDriver BiDi implemented. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L44" >}} {{% /tab %}} {{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_script.py#L8-L9" >}} +{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_script.py#L10-L11" >}} {{% /tab %}} {{% tab header="CSharp" %}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/ScriptTest.cs#L39-L46" >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/cdp/script.ja.md b/website_and_docs/content/documentation/webdriver/bidi/cdp/script.ja.md index b721b93f9b3c..aad235f720dc 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/cdp/script.ja.md +++ b/website_and_docs/content/documentation/webdriver/bidi/cdp/script.ja.md @@ -51,7 +51,7 @@ methods will eventually be removed when WebDriver BiDi implemented. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L44" >}} {{% /tab %}} {{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_script.py#L8-L9" >}} +{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_script.py#L10-L11" >}} {{% /tab %}} {{% tab header="CSharp" %}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/ScriptTest.cs#L39-L46" >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/cdp/script.pt-br.md b/website_and_docs/content/documentation/webdriver/bidi/cdp/script.pt-br.md index 343170fe5404..bc76016f1eda 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/cdp/script.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/bidi/cdp/script.pt-br.md @@ -51,7 +51,7 @@ methods will eventually be removed when WebDriver BiDi implemented. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L44" >}} {{% /tab %}} {{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_script.py#L8-L9" >}} +{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_script.py#L10-L11" >}} {{% /tab %}} {{% tab header="CSharp" %}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/ScriptTest.cs#L39-L46" >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/cdp/script.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidi/cdp/script.zh-cn.md index d7f287bd3dff..f4f25d5c09b0 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/cdp/script.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/bidi/cdp/script.zh-cn.md @@ -51,7 +51,7 @@ methods will eventually be removed when WebDriver BiDi implemented. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L44" >}} {{% /tab %}} {{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_script.py#L8-L9" >}} +{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_script.py#L10-L11" >}} {{% /tab %}} {{% tab header="CSharp" %}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/ScriptTest.cs#L39-L46" >}}