Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[馃殌 Feature]: Add instructions for Python in the 'Test Runners' section #1474

Open
Ankit3794 opened this issue Sep 13, 2023 · 2 comments

Comments

@Ankit3794
Copy link

Feature and motivation

There are currently no instructions in the Test Runners section for Python. I would like to contribute the following:


Pytest

Install pytest dependency

pip install pytest

Now, run test using:

pytest

Unittest

Save the script to test_web_form.py file

import unittest
from selenium import webdriver
from selenium.webdriver.common.by import By

class TestWebForm(unittest.TestCase):

    def setUp(self):
        self.driver = webdriver.Chrome()

    def tearDown(self):
        self.driver.quit()

    def test_eight_components(self):
        self.driver.get("https://www.selenium.dev/selenium/web/web-form.html")

        title = self.driver.title
        self.assertEqual(title, "Web form")

        self.driver.implicitly_wait(0.5)

        text_box = self.driver.find_element(by=By.NAME, value="my-text")
        submit_button = self.driver.find_element(by=By.CSS_SELECTOR, value="button")

        text_box.send_keys("Selenium")
        submit_button.click()

        message = self.driver.find_element(by=By.ID, value="message")
        value = message.text
        self.assertEqual(value, "Received!")

if __name__ == "__main__":
    unittest.main()

Run the file with using:

python test_web_form.py

@github-actions
Copy link
Contributor

@Ankit3794, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@titusfortner
Copy link
Member

I'm looking to try to move this test runners section to a new page with #1479

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants