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://ift.tt/1yKv6jo"
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?
Thanks,
Andrea
Aucun commentaire:
Enregistrer un commentaire