A
A
adun32017-02-28 19:44:13
selenium
adun3, 2017-02-28 19:44:13

Wrote tests, now how to run them in docker?

Hello!
I wrote 2 small tests to check the login and the performance of links on the site: 1.py, 2.py
they are almost the same, here is one of them:

# -*- coding: utf-8 -*-
from selenium import webdriver
from pyvirtualdisplay import Display
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re

class LoginTest(unittest.TestCase):
    def setUp(self):
        self.display = Display(visible=0, size=(1280, 1024))
        self.display.start()
        self.driver = webdriver.Chrome(executable_path='/home/chingis/selenuim/chromedriver')
        self.verificationErrors = []
        self.accept_next_alert = True

    def test_1(self):
        links = ["http://127.0.0.1:8000/login", "http://127.0.0.1:8000/popular/", "http://127.0.0.1:8000/upcoming/", "http://127.0.0.1:8000"]
        driver = self.driver
        for link in links:
            driver.get(link)
            msg = "error with link" + link
            self.assertTrue(driver.find_element_by_class_name("classname"), msg)

    def tearDown(self):
        self.driver.quit()
        self.assertEqual([], self.verificationErrors)

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

Here several questions arise. AssertTrue does not give an error (broken link), but it's clear where to dig (try except you need to look, in python it's like in the jungle).
1) How to deal with multiple browsers (here only 1)? Write a function that returns a driver?
2) How now with these 2 tests to squeeze into the docker (1 file seems to be with instructions)?
3) If there is a test for login, do you need to test the logout in the same test?
Sorry for my laziness, tomorrow I'll go look for myself, maybe someone will send faster. Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question