Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8897737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:25:30+00:00 2026-06-15T00:25:30+00:00

I am a newbie in selenium automation. I have created a Selenium test case

  • 0

I am a newbie in selenium automation. I have created a Selenium test case & test suite.
I exported the test suite as a Python webdriver.

How should I execute this python code?
I tried this:

./pythonwebdriver <selenium test case.html>

I get this error:

Traceback (most recent call last):
File "./pythondriver.py", line 52, in <module>
unittest.main()
File "/usr/lib/python2.7/unittest/main.py", line 94, in __init__
self.parseArgs(argv)
File "/usr/lib/python2.7/unittest/main.py", line 149, in parseArgs
self.createTests()
File "/usr/lib/python2.7/unittest/main.py", line 158, in createTests
self.module)
File "/usr/lib/python2.7/unittest/loader.py", line 128, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "/usr/lib/python2.7/unittest/loader.py", line 100, in loadTestsFromName
parent, obj = obj, getattr(obj, part)
AttributeError: 'module' object has no attribute '<testcasename>'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:25:31+00:00Added an answer on June 15, 2026 at 12:25 am

    There is no such thing as Python webdriver. Webdriver is a component for driving webpages. It has been integrated to the Selenium 2. Natively it works in Java, but there are bindings available for many languages, including Python.

    Here’s an annotated example from the webdriver documentation modified a little. For creating a unittest, make a test class that inherits the class TestCase provided by unittest module.

    #!/usr/bin/python
    
    from selenium import webdriver
    from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
    import unittest
    
    class GoogleTest(unittest.TestCase):
        def test_basic_search(self):
            # Create a new instance of the Firefox driver
            driver = webdriver.Firefox()
            driver.implicitly_wait(10)
    
            # go to the google home page
            driver.get("http://www.google.com")
    
            # find the element that's name attribute is q (the google search box)
            inputElement = driver.find_element_by_name("q")
    
            # type in the search
            inputElement.send_keys("Cheese!")
    
            # submit the form (although google automatically searches 
            # now without submitting)
            inputElement.submit()
    
            # the page is ajaxy so the title is originally this:
            original_title = driver.title
    
            try:
                # we have to wait for the page to refresh, the last thing 
                # that seems to be updated is the title
                WebDriverWait(driver, 10).until(lambda driver :  
                                         driver.title != original_title)
                self.assertIn("cheese!", driver.title.lower())
    
                # You should see "cheese! - Google Search"
                print driver.title
            finally:
                driver.quit()
    
    if __name__ == '__main__':
        unittest.main()
    

    One nice thing about webdriver is that you can change the driver line to be

    driver = webdriver.Chrome()
    driver = webdriver.Firefox()
    driver = webdriver.Ie()
    

    depending on what browsers you need to test. In addition to ChromeDriver, FirefoxDriver or InternetExplorerDriver there’s also HtmlUnitDriver which is most lightweight and can run headless (but may run some javascript differently than browsers), RemoteWebDriver which allows running tests on remote machines and in parallel, and many others (iPhone, Android, Safari, Opera).

    Running it can be done as running any python script. Either just with:

    python <script_name.py>
    

    or including the interpreter name on the first line like !#/usr/bin/python above. The last two lines

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

    make the script run the test when this file is run directly like ./selenium_test.py. It is also possible to collect test cases automatically from multiple files and run them together (see unittest documentation). Another way running tests in some module or some individual test is

    python -m unittest selenium_test.GoogleTest
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Newbie in testing. I generated a test case using Selenium, and then exported it
I'm fairly new at Python/JS and also automated testing with Selenium/WebDriver, but I have
Newbie question. I have Django models that look like this: class Video(models.Model): uploaded_by =
I am newbie with Selenium Grid therefore any help in this regard is much
I'm a complete selenium newbie. Where should I start if I want to learn
Newbie question here but for some reason I cant figure this out. I have
I am a newbie to Selenium and is implementing selenium-rc with Python client library.
Newbie question, let me try and make this as clear as possible. I have
Newbie-Problem: I have a small test-class (TestLibMain.cpp) in c++ an compiled it to a
Newbie GitHub question: I have setup an organization in GitHub and created a private

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.