diff --git a/examples/python/requirements.txt b/examples/python/requirements.txt index 42a3902ce8d..b3661c6d068 100644 --- a/examples/python/requirements.txt +++ b/examples/python/requirements.txt @@ -1,7 +1,7 @@ selenium==4.27.1 -pytest -trio -pytest-trio -pytest-rerunfailures -flake8 -requests +pytest==8.3.4 +trio==0.27.0 +pytest-trio==0.8.0 +pytest-rerunfailures==14.0 +flake8==7.1.1 +requests==2.32.3 diff --git a/examples/python/tests/elements/test_locators.py b/examples/python/tests/elements/test_locators.py index 53b695b6fc8..3622b70d97f 100644 --- a/examples/python/tests/elements/test_locators.py +++ b/examples/python/tests/elements/test_locators.py @@ -1,2 +1,84 @@ +import pytest from selenium import webdriver +from selenium.webdriver.common.by import By + +def test_class_name(): + driver = webdriver.Chrome() + driver.get("https://www.selenium.dev/selenium/web/locators_tests/locators.html") + element = driver.find_element(By.CLASS_NAME, "information") + + assert element is not None + assert element.tag_name == "input" + + driver.quit() + +def test_css_selector(driver): + driver = webdriver.Chrome() + driver.get("https://www.selenium.dev/selenium/web/locators_tests/locators.html") + element = driver.find_element(By.CSS_SELECTOR, "#fname") + + assert element is not None + assert element.get_attribute("value") == "Jane" + + driver.quit() + +def test_id(driver): + driver = webdriver.Chrome() + driver.get("https://www.selenium.dev/selenium/web/locators_tests/locators.html") + element = driver.find_element(By.ID, "lname") + + assert element is not None + assert element.get_attribute("value") == "Doe" + + driver.quit() + +def test_name(driver): + driver = webdriver.Chrome() + driver.get("https://www.selenium.dev/selenium/web/locators_tests/locators.html") + element = driver.find_element(By.NAME, "newsletter") + + assert element is not None + assert element.tag_name == "input" + + driver.quit() + +def test_link_text(driver): + driver = webdriver.Chrome() + driver.get("https://www.selenium.dev/selenium/web/locators_tests/locators.html") + element = driver.find_element(By.LINK_TEXT, "Selenium Official Page") + + assert element is not None + assert element.get_attribute("href") == "https://www.selenium.dev/" + + driver.quit() + +def test_partial_link_text(driver): + driver = webdriver.Chrome() + driver.get("https://www.selenium.dev/selenium/web/locators_tests/locators.html") + element = driver.find_element(By.PARTIAL_LINK_TEXT, "Official Page") + + assert element is not None + assert element.get_attribute("href") == "https://www.selenium.dev/" + + driver.quit() + +def test_tag_name(driver): + driver = webdriver.Chrome() + driver.get("https://www.selenium.dev/selenium/web/locators_tests/locators.html") + element = driver.find_element(By.TAG_NAME, "a") + + assert element is not None + assert element.get_attribute("href") == "https://www.selenium.dev/" + + driver.quit() + +def test_xpath(driver): + driver = webdriver.Chrome() + driver.get("https://www.selenium.dev/selenium/web/locators_tests/locators.html") + element = driver.find_element(By.XPATH, "//input[@value='f']") + + assert element is not None + assert element.get_attribute("type") == "radio" + + driver.quit() diff --git a/website_and_docs/content/documentation/webdriver/elements/locators.en.md b/website_and_docs/content/documentation/webdriver/elements/locators.en.md index d08963fd063..865c2910f9f 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.en.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.en.md @@ -49,7 +49,7 @@ page. To understand and create locator we will use the following HTML snippet.

Contact Selenium

-
+ Male   Female

@@ -80,10 +80,9 @@ available in Selenium. WebDriver driver = new ChromeDriver(); driver.findElement(By.className("information")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.CLASS_NAME, "information") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L7-L9" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.ClassName("information")); @@ -114,10 +113,9 @@ textbox, using css. WebDriver driver = new ChromeDriver(); driver.findElement(By.cssSelector("#fname")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.CSS_SELECTOR, "#fname") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L17-L19" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.CssSelector("#fname")); @@ -146,10 +144,9 @@ We will identify the Last Name field using it. WebDriver driver = new ChromeDriver(); driver.findElement(By.id("lname")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.ID, "lname") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L27-L29" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.Id("lname")); @@ -179,10 +176,9 @@ We will identify the Newsletter checkbox using it. WebDriver driver = new ChromeDriver(); driver.findElement(By.name("newsletter")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.NAME, "newsletter") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L37-L39" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.Name("newsletter")); @@ -210,10 +206,9 @@ In the HTML snippet shared, we have a link available, let's see how will we loca WebDriver driver = new ChromeDriver(); driver.findElement(By.linkText("Selenium Official Page")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.LINK_TEXT, "Selenium Official Page") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L47-L49" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.LinkText("Selenium Official Page")); @@ -242,10 +237,9 @@ In the HTML snippet shared, we have a link available, lets see how will we locat WebDriver driver = new ChromeDriver(); driver.findElement(By.partialLinkText("Official Page")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.PARTIAL_LINK_TEXT, "Official Page") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L57-L59" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.PartialLinkText("Official Page")); @@ -272,10 +266,9 @@ From the above HTML snippet shared, lets identify the link, using its html tag " WebDriver driver = new ChromeDriver(); driver.findElement(By.tagName("a")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.TAG_NAME, "a") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L67-L69" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.TagName("a")); @@ -308,10 +301,9 @@ first name text box. Let us create locator for female radio button using xpath. WebDriver driver = new ChromeDriver(); driver.findElement(By.xpath("//input[@value='f']")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.XPATH, "//input[@value='f']") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L77-L79" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.Xpath("//input[@value='f']")); diff --git a/website_and_docs/content/documentation/webdriver/elements/locators.ja.md b/website_and_docs/content/documentation/webdriver/elements/locators.ja.md index 28b11bcd66c..f28ed13f85b 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.ja.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.ja.md @@ -48,7 +48,7 @@ page. To understand and create locator we will use the following HTML snippet.

Contact Selenium

- + Male   Female

@@ -78,10 +78,9 @@ available in Selenium. WebDriver driver = new ChromeDriver(); driver.findElement(By.className("information")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.CLASS_NAME, "information") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L7-L9" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.ClassName("information")); @@ -111,10 +110,9 @@ textbox, using css. WebDriver driver = new ChromeDriver(); driver.findElement(By.cssSelector("#fname")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.CSS_SELECTOR, "#fname") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L17-L19" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.CssSelector("#fname")); @@ -142,10 +140,9 @@ We will identify the Last Name field using it. WebDriver driver = new ChromeDriver(); driver.findElement(By.id("lname")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.ID, "lname") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L27-L29" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.Id("lname")); @@ -174,10 +171,9 @@ We will identify the Newsletter checkbox using it. WebDriver driver = new ChromeDriver(); driver.findElement(By.name("newsletter")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.NAME, "newsletter") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L37-L39" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.Name("newsletter")); @@ -204,10 +200,9 @@ In the HTML snippet shared, we have a link available, lets see how will we locat WebDriver driver = new ChromeDriver(); driver.findElement(By.linkText("Selenium Official Page")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.LINK_TEXT, "Selenium Official Page") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L47-L49" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.LinkText("Selenium Official Page")); @@ -235,10 +230,9 @@ In the HTML snippet shared, we have a link available, lets see how will we locat WebDriver driver = new ChromeDriver(); driver.findElement(By.partialLinkText("Official Page")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.PARTIAL_LINK_TEXT, "Official Page") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L57-L59" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.PartialLinkText("Official Page")); @@ -264,10 +258,9 @@ From the above HTML snippet shared, lets identify the link, using its html tag " WebDriver driver = new ChromeDriver(); driver.findElement(By.tagName("a")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.TAG_NAME, "a") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L67-L69" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.TagName("a")); @@ -299,10 +292,9 @@ first name text box. Let us create locator for female radio button using xpath. WebDriver driver = new ChromeDriver(); driver.findElement(By.xpath("//input[@value='f']")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.XPATH, "//input[@value='f']") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L77-L79" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.Xpath("//input[@value='f']")); diff --git a/website_and_docs/content/documentation/webdriver/elements/locators.pt-br.md b/website_and_docs/content/documentation/webdriver/elements/locators.pt-br.md index de57a4812d3..f50ac162eff 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.pt-br.md @@ -51,7 +51,7 @@ page. To understand and create locator we will use the following HTML snippet.

Contact Selenium

- + Male   Female

@@ -81,10 +81,9 @@ available in Selenium. WebDriver driver = new ChromeDriver(); driver.findElement(By.className("information")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.CLASS_NAME, "information") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L7-L9" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.ClassName("information")); @@ -114,10 +113,9 @@ textbox, using css. WebDriver driver = new ChromeDriver(); driver.findElement(By.cssSelector("#fname")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.CSS_SELECTOR, "#fname") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L17-L19" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.CssSelector("#fname")); @@ -145,10 +143,9 @@ We will identify the Last Name field using it. WebDriver driver = new ChromeDriver(); driver.findElement(By.id("lname")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.ID, "lname") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L27-L29" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.Id("lname")); @@ -177,10 +174,9 @@ We will identify the Newsletter checkbox using it. WebDriver driver = new ChromeDriver(); driver.findElement(By.name("newsletter")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.NAME, "newsletter") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L37-L39" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.Name("newsletter")); @@ -207,10 +203,9 @@ In the HTML snippet shared, we have a link available, lets see how will we locat WebDriver driver = new ChromeDriver(); driver.findElement(By.linkText("Selenium Official Page")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.LINK_TEXT, "Selenium Official Page") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L47-L49" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.LinkText("Selenium Official Page")); @@ -238,10 +233,9 @@ In the HTML snippet shared, we have a link available, lets see how will we locat WebDriver driver = new ChromeDriver(); driver.findElement(By.partialLinkText("Official Page")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.PARTIAL_LINK_TEXT, "Official Page") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L57-L59" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.PartialLinkText("Official Page")); @@ -267,10 +261,9 @@ From the above HTML snippet shared, lets identify the link, using its html tag " WebDriver driver = new ChromeDriver(); driver.findElement(By.tagName("a")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.TAG_NAME, "a") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L67-L69" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.TagName("a")); @@ -302,10 +295,9 @@ first name text box. Let us create locator for female radio button using xpath. WebDriver driver = new ChromeDriver(); driver.findElement(By.xpath("//input[@value='f']")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.XPATH, "//input[@value='f']") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L77-L79" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.Xpath("//input[@value='f']")); diff --git a/website_and_docs/content/documentation/webdriver/elements/locators.zh-cn.md b/website_and_docs/content/documentation/webdriver/elements/locators.zh-cn.md index b8e38f81faf..7681f487f5a 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.zh-cn.md @@ -51,7 +51,7 @@ page. To understand and create locator we will use the following HTML snippet.

Contact Selenium

- + Male   Female

@@ -81,10 +81,9 @@ available in Selenium. WebDriver driver = new ChromeDriver(); driver.findElement(By.className("information")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.CLASS_NAME, "information") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L7-L9" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.ClassName("information")); @@ -114,10 +113,9 @@ textbox, using css. WebDriver driver = new ChromeDriver(); driver.findElement(By.cssSelector("#fname")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.CSS_SELECTOR, "#fname") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L17-L19" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.CssSelector("#fname")); @@ -145,10 +143,9 @@ We will identify the Last Name field using it. WebDriver driver = new ChromeDriver(); driver.findElement(By.id("lname")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.ID, "lname") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L27-L29" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.Id("lname")); @@ -177,10 +174,9 @@ We will identify the Newsletter checkbox using it. WebDriver driver = new ChromeDriver(); driver.findElement(By.name("newsletter")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.NAME, "newsletter") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L37-L39" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.Name("newsletter")); @@ -207,10 +203,9 @@ In the HTML snippet shared, we have a link available, lets see how will we locat WebDriver driver = new ChromeDriver(); driver.findElement(By.linkText("Selenium Official Page")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.LINK_TEXT, "Selenium Official Page") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L47-L49" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.LinkText("Selenium Official Page")); @@ -238,10 +233,9 @@ In the HTML snippet shared, we have a link available, lets see how will we locat WebDriver driver = new ChromeDriver(); driver.findElement(By.partialLinkText("Official Page")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.PARTIAL_LINK_TEXT, "Official Page") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L57-L59" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.PartialLinkText("Official Page")); @@ -267,10 +261,9 @@ From the above HTML snippet shared, lets identify the link, using its html tag " WebDriver driver = new ChromeDriver(); driver.findElement(By.tagName("a")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.TAG_NAME, "a") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L67-L69" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.TagName("a")); @@ -302,10 +295,9 @@ first name text box. Let us create locator for female radio button using xpath. WebDriver driver = new ChromeDriver(); driver.findElement(By.xpath("//input[@value='f']")); {{< /tab >}} - {{< tab header="Python" >}} - driver = webdriver.Chrome() - driver.find_element(By.XPATH, "//input[@value='f']") - {{< /tab >}} +{{< tab header="Python" text=true >}} +{{< gh-codeblock path="/examples/python/tests/elements/test_locators.py#L77-L79" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.Xpath("//input[@value='f']")); diff --git a/website_and_docs/content/documentation/webdriver/interactions/print_page.en.md b/website_and_docs/content/documentation/webdriver/interactions/print_page.en.md index 5a900b1f219..450693c4c91 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/print_page.en.md +++ b/website_and_docs/content/documentation/webdriver/interactions/print_page.en.md @@ -29,7 +29,7 @@ Using the `getOrientation()` and `setOrientation()` methods, you can get/set the {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L11-L15" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L12-L14" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -53,7 +53,7 @@ Using the `getPageRanges()` and `setPageRanges()` methods, you can get/set the r {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L17-L21" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L18-L20" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -77,7 +77,7 @@ Using the `getPaperSize()` and `setPaperSize()` methods, you can get/set the pap {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L23-L27" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L24-L26" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -101,7 +101,7 @@ Using the `getPageMargin()` and `setPageMargin()` methods, you can set the margi {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L29-L39" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L30-L35" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -125,7 +125,7 @@ Using `getScale()` and `setScale()` methods, you can get/set the scale of the pa {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L41-L46" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L42-L45" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -149,7 +149,7 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether b {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L48-L52" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L49-L51" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -173,7 +173,7 @@ Using `getShrinkToFit()` and `setShrinkToFit()` methods, you can get/set whether {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L54-L58" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L55-L57" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -212,7 +212,7 @@ Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable B {{< /tab >}} {{% tab header="Python" %}} **print_page()** -{{< gh-codeblock path="examples/python/tests/interactions/test_prints_page.py#L11-L15" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_prints_page.py#L12-L14" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} diff --git a/website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md b/website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md index 40b19d6029f..6fdf2001b52 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md +++ b/website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md @@ -29,7 +29,7 @@ Using the `getOrientation()` and `setOrientation()` methods, you can get/set the {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L11-L15" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L12-L14" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -53,7 +53,7 @@ Using the `getPageRanges()` and `setPageRanges()` methods, you can get/set the r {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L17-L21" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L18-L20" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -77,7 +77,7 @@ Using the `getPaperSize()` and `setPaperSize()` methods, you can get/set the pap {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L23-L27" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L24-L26" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -101,7 +101,7 @@ Using the `getPageMargin()` and `setPageMargin()` methods, you can set the margi {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L29-L39" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L30-L35" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -125,7 +125,7 @@ Using `getScale()` and `setScale()` methods, you can get/set the scale of the pa {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L41-L46" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L42-L45" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -149,7 +149,7 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether b {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L48-L52" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L49-L51" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -173,7 +173,7 @@ Using `getShrinkToFit()` and `setShrinkToFit()` methods, you can get/set whether {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L54-L58" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L55-L57" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -212,7 +212,7 @@ Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable B {{< /tab >}} {{% tab header="Python" %}} **print_page()** -{{< gh-codeblock path="examples/python/tests/interactions/test_prints_page.py#L11-L15" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_prints_page.py#L12-L14" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} diff --git a/website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md b/website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md index 5600370d175..52515ecb412 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md @@ -29,7 +29,7 @@ Using the `getOrientation()` and `setOrientation()` methods, you can get/set the {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L11-L15" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L12-L14" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -53,7 +53,7 @@ Using the `getPageRanges()` and `setPageRanges()` methods, you can get/set the r {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L17-L21" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L18-L26" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -77,7 +77,7 @@ Using the `getPaperSize()` and `setPaperSize()` methods, you can get/set the pap {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L23-L27" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L24-L27" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -101,7 +101,7 @@ Using the `getPageMargin()` and `setPageMargin()` methods, you can set the margi {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L29-L39" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L30-L35" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -125,7 +125,7 @@ Using `getScale()` and `setScale()` methods, you can get/set the scale of the pa {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L41-L46" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L42-L45" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -149,7 +149,7 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether b {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L48-L52" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L49-L51" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -173,7 +173,7 @@ Using `getShrinkToFit()` and `setShrinkToFit()` methods, you can get/set whether {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L54-L58" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L55-L57" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -212,7 +212,7 @@ Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable B {{< /tab >}} {{% tab header="Python" %}} **print_page()** -{{< gh-codeblock path="examples/python/tests/interactions/test_prints_page.py#L11-L15" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_prints_page.py#L12-L14" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} diff --git a/website_and_docs/content/documentation/webdriver/interactions/print_page.zh-cn.md b/website_and_docs/content/documentation/webdriver/interactions/print_page.zh-cn.md index f25d7cc9427..0f9f5c7718d 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/print_page.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/interactions/print_page.zh-cn.md @@ -27,7 +27,7 @@ Selenium 通过其 PrintOptions、PrintsPage 和 browsingContext 类简化了这 {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L11-L15" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L12-L14" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -51,7 +51,7 @@ Selenium 通过其 PrintOptions、PrintsPage 和 browsingContext 类简化了这 {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L17-L21" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L18-L20" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -75,7 +75,7 @@ Selenium 通过其 PrintOptions、PrintsPage 和 browsingContext 类简化了这 {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L23-L27" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L24-L26" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -99,7 +99,7 @@ Selenium 通过其 PrintOptions、PrintsPage 和 browsingContext 类简化了这 {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L29-L39" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L30-L35" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -123,7 +123,7 @@ Selenium 通过其 PrintOptions、PrintsPage 和 browsingContext 类简化了这 {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L41-L46" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L42-L45" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -147,7 +147,7 @@ Selenium 通过其 PrintOptions、PrintsPage 和 browsingContext 类简化了这 {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L48-L52" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L49-L51" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -171,7 +171,7 @@ Selenium 通过其 PrintOptions、PrintsPage 和 browsingContext 类简化了这 {{< badge-implementation >}} {{< /tab >}} {{< tab header="Python" >}} -{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L54-L58" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L55-L57" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}} @@ -208,7 +208,7 @@ Selenium 通过其 PrintOptions、PrintsPage 和 browsingContext 类简化了这 {{< /tab >}} {{% tab header="Python" %}} **print_page()** -{{< gh-codeblock path="examples/python/tests/interactions/test_prints_page.py#L11-L15" >}} +{{< gh-codeblock path="examples/python/tests/interactions/test_prints_page.py#L12-L14" >}} {{< /tab >}} {{< tab header="JavaScript" >}} {{< badge-implementation >}}