From 11cf4f1ef436f94a6a30e84ccc17507824188b58 Mon Sep 17 00:00:00 2001 From: Navin Chandra Date: Mon, 16 Dec 2024 14:44:04 +0530 Subject: [PATCH 1/2] move python code to test_locators.py --- examples/python/tests/conftest.py | 20 +++++++ examples/python/tests/elements/locators.html | 30 ++++++++++ .../python/tests/elements/test_locators.py | 52 +++++++++++++++++ .../webdriver/elements/locators.en.md | 56 ++++++++----------- .../webdriver/elements/locators.ja.md | 56 ++++++++----------- .../webdriver/elements/locators.pt-br.md | 56 ++++++++----------- .../webdriver/elements/locators.zh-cn.md | 56 ++++++++----------- 7 files changed, 198 insertions(+), 128 deletions(-) create mode 100644 examples/python/tests/elements/locators.html diff --git a/examples/python/tests/conftest.py b/examples/python/tests/conftest.py index caf63c070ea3..72516ef82feb 100644 --- a/examples/python/tests/conftest.py +++ b/examples/python/tests/conftest.py @@ -9,6 +9,8 @@ from urllib.request import urlopen import requests from requests.auth import HTTPBasicAuth +from http.server import HTTPServer, SimpleHTTPRequestHandler +from threading import Thread import pytest from selenium import webdriver @@ -188,6 +190,24 @@ def wait_for_server(url, timeout): print("Selenium server has been terminated") +@pytest.fixture(scope="session") +def html_server(): + """ + Start an HTTP server to serve files from the `tests/` directory. + """ + elements_dir = os.path.join(os.path.dirname(os.path.abspath(__file__))) + os.chdir(elements_dir) + port = free_port() + server = HTTPServer(("localhost", port), SimpleHTTPRequestHandler) + + thread = Thread(target=server.serve_forever, daemon=True) + thread.start() + + yield f"http://localhost:{port}" + + server.shutdown() + + @pytest.fixture(scope="function") def server(): _host = "localhost" diff --git a/examples/python/tests/elements/locators.html b/examples/python/tests/elements/locators.html new file mode 100644 index 000000000000..01073abf7f3f --- /dev/null +++ b/examples/python/tests/elements/locators.html @@ -0,0 +1,30 @@ + + + +

Contact Selenium

+ +
+ Male   + Female
+
+
+

+
+

+ +

+ +
+ +

To know more about Selenium, visit the official page +Selenium Official Page +

+ + + diff --git a/examples/python/tests/elements/test_locators.py b/examples/python/tests/elements/test_locators.py index 53b695b6fc83..8aa97bc88d98 100644 --- a/examples/python/tests/elements/test_locators.py +++ b/examples/python/tests/elements/test_locators.py @@ -1,2 +1,54 @@ +import pytest from selenium import webdriver +from selenium.webdriver.common.by import By +@pytest.fixture +def driver(html_server): + """ + Initialize the WebDriver and navigate to the elements/locators.html page. + """ + driver = webdriver.Chrome() + driver.implicitly_wait(0.5) + driver.get(f"{html_server}/elements/locators.html") + yield driver + driver.quit() + +def test_class_name(driver): + element = driver.find_element(By.CLASS_NAME, "information") + assert element is not None + assert element.tag_name == "input" + +def test_css_selector(driver): + element = driver.find_element(By.CSS_SELECTOR, "#fname") + assert element is not None + assert element.get_attribute("value") == "Jane" + +def test_id(driver): + element = driver.find_element(By.ID, "lname") + assert element is not None + assert element.get_attribute("value") == "Doe" + +def test_name(driver): + element = driver.find_element(By.NAME, "newsletter") + assert element is not None + assert element.tag_name == "input" + +def test_link_text(driver): + element = driver.find_element(By.LINK_TEXT, "Selenium Official Page") + assert element is not None + assert element.get_attribute("href") == "https://www.selenium.dev/" + +def test_partial_link_text(driver): + element = driver.find_element(By.PARTIAL_LINK_TEXT, "Official Page") + assert element is not None + assert element.get_attribute("href") == "https://www.selenium.dev/" + +def test_tag_name(driver): + element = driver.find_element(By.TAG_NAME, "a") + assert element is not None + assert element.get_attribute("href") == "https://www.selenium.dev/" + +def test_xpath(driver): + element = driver.find_element(By.XPATH, "//input[@value='f']") + assert element is not None + assert element.get_attribute("type") == "radio" 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 d08963fd063d..d800d40afa95 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.en.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.en.md @@ -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#L17" >}} +{{< /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#L22" >}} +{{< /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" >}} +{{< /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#L32" >}} +{{< /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#L37" >}} +{{< /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#L42" >}} +{{< /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#L47" >}} +{{< /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#L52" >}} +{{< /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 28b11bcd66cc..b35c33c11309 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.ja.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.ja.md @@ -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#L17" >}} +{{< /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#L22" >}} +{{< /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" >}} +{{< /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#L32" >}} +{{< /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#L37" >}} +{{< /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#L42" >}} +{{< /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#L47" >}} +{{< /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#L52" >}} +{{< /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 de57a4812d37..784b97422256 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 @@ -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#L17" >}} +{{< /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#L22" >}} +{{< /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" >}} +{{< /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#L32" >}} +{{< /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#L37" >}} +{{< /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#L42" >}} +{{< /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#L47" >}} +{{< /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#L52" >}} +{{< /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 b8e38f81faff..133e30561886 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 @@ -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#L17" >}} +{{< /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#L22" >}} +{{< /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" >}} +{{< /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#L32" >}} +{{< /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#L37" >}} +{{< /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#L42" >}} +{{< /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#L47" >}} +{{< /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#L52" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); driver.FindElement(By.Xpath("//input[@value='f']")); From 45aa8579d6ecb053dd96fe38b313e1d3530e135b Mon Sep 17 00:00:00 2001 From: Navin Chandra Date: Fri, 20 Dec 2024 00:00:22 +0530 Subject: [PATCH 2/2] remove action_page.php --- examples/python/tests/elements/locators.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/python/tests/elements/locators.html b/examples/python/tests/elements/locators.html index 01073abf7f3f..881bcba2d95d 100644 --- a/examples/python/tests/elements/locators.html +++ b/examples/python/tests/elements/locators.html @@ -9,7 +9,7 @@

Contact Selenium

-
+ Male   Female