-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[py]: move python code to test_locators.py
#2102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
11cf4f1
move python code to test_locators.py
navin772 45aa857
remove action_page.php
navin772 8b06743
Merge branch 'trunk' into py-locators
harsha509 f602128
Merge branch 'trunk' into py-locators
navin772 4194a2f
remove html file and reference html from `selenium.dev/selenium/web`
navin772 d0d1eaa
Merge branch 'trunk' into py-locators
harsha509 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<html> | ||
<body> | ||
<style> | ||
.information { | ||
background-color: white; | ||
color: black; | ||
padding: 10px; | ||
} | ||
</style> | ||
<h2>Contact Selenium</h2> | ||
|
||
<form action="/action_page.php"> | ||
<input type="radio" name="gender" value="m" />Male | ||
<input type="radio" name="gender" value="f" />Female <br> | ||
<br> | ||
<label for="fname">First name:</label><br> | ||
<input class="information" type="text" id="fname" name="fname" value="Jane"><br><br> | ||
<label for="lname">Last name:</label><br> | ||
<input class="information" type="text" id="lname" name="lname" value="Doe"><br><br> | ||
<label for="newsletter">Newsletter:</label> | ||
<input type="checkbox" name="newsletter" value="1" /><br><br> | ||
<input type="submit" value="Submit"> | ||
</form> | ||
|
||
<p>To know more about Selenium, visit the official page | ||
<a href ="https://www.selenium.dev/">Selenium Official Page</a> | ||
</p> | ||
|
||
</body> | ||
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.