2

I wrote, in Python, using Selenium, a very simple test of a webpage

Here the code:

from selenium import webdriver
import unittest
from selenium.webdriver.common.keys import Keys

class NewVisitorTest(unittest.TestCase):

    def setUp(self):
    # cose da fare prima dei test
        self.browser = webdriver.Firefox()  # Opera? credo sia usabile :D

    def tearDown(self):
    # cose da fare dopo dei test
        self.browser.quit()

    def test_yahoo(self):
        # browser = webdriver.Firefox() # Get local session of firefox
        pagina = "http://ricordandoti.net/it/app-per-scoprire-il-cimitero-del-poblenou/"
        self.browser.get(pagina)      # Load page
        self.browser.implicitly_wait(5)    # aspetto si carichi tutta la pagina
                                           # forzando di aspettare 3 s
        assert "Ricordandoti" in self.browser.title


if __name__ == '__main__':  # 7    
    unittest.main(warnings='ignore')

It works, but it takes almost a minute to be executed:

> Running: /home/.../tests/functional_tests_ricord.py (Wed Jan 21 13:32:05 2015)
> 
> .
> ---------------------------------------------------------------------- Ran 1 test in 60.798s
> 
> OK

I use ninja IDE to write the code (in a Ubuntu 14.04 machine). This seems to be the reason.

Executing code directly from shell, it takes 20 s:

> subu@VR46-U:~$ python3 "/home/.../tests/functional_tests_ricord.py"
.
----------------------------------------------------------------------
Ran 1 test in 20.865s

OK

What can I do to fast up the execution?

1

1 Answer 1

1

The following should speed things up for you:

  • upgrade selenium to the latest version (currently 2.44.0)

    pip3 install selenium --upgrade
    
  • upgrade firefox to the latest version (currently 35.0)

It was slower on my end before the upgrades, now it is:

$ python3 test.py
.
----------------------------------------------------------------------
Ran 1 test in 6.258s

OK
Sign up to request clarification or add additional context in comments.

1 Comment

May be is as you say. Unfortunatly I can't update selenium the way you suggest.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.