class profile_events_three_tabs_present(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_profile_events_three_tabs_present(self):
        success = True
        wd = self.wd
        wd.get(str(Baseurl.baseurl))
        wd.find_element_by_link_text("Войти").click()
        wd.find_element_by_id("UserForm_email").click()
        wd.find_element_by_id("UserForm_email").clear()
        wd.find_element_by_id("UserForm_email").send_keys("*****@*****.**")
        wd.find_element_by_id("UserForm_password").click()
        wd.find_element_by_id("UserForm_password").clear()
        wd.find_element_by_id("UserForm_password").send_keys("1111")
        wd.find_element_by_id("submit_link").click()
        wd.find_element_by_xpath("//ul[@id='yw2']//a[.='Мероприятия']").click()
        if not (len(wd.find_elements_by_xpath("//div[@class='company-box__section']//a[@href='#tab01']")) != 0):
            success = False
            print("verifyElementPresent failed")
        if not (len(wd.find_elements_by_xpath("//div[@class='company-box__section']//a[@href='#tab02']")) != 0):
            success = False
            print("verifyElementPresent failed")
        if not (len(wd.find_elements_by_xpath("//div[@class='company-box__section']//a[@href='#tab03']")) != 0):
            success = False
            print("verifyElementPresent failed")
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
Beispiel #2
0
class rent_sale_filters(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_rent_sale_filters(self):
        success = True
        wd = self.wd
        wd.get(str(Baseurl.baseurl) + "catalog/video_13/videokameri-i-kamkorderi_128/")
        wd.find_element_by_xpath("//label[.='Только аренда']").click()
        if wd.current_url != str(Baseurl.baseurl) + "catalog/video_13/videokameri-i-kamkorderi_128/?offerType=rent":
            success = False
            print("verifyCurrentUrl failed")
        wait(wd, 10).until(lambda s: "Средняя цена аренды" in wd.find_element_by_xpath("//div[@class='reviews__price']").text)
        wd.find_element_by_xpath("//label[.='Только продажа']").click()
        if wd.current_url != str(Baseurl.baseurl) + "catalog/video_13/videokameri-i-kamkorderi_128/?offerType=sale":
            success = False
            print("verifyCurrentUrl failed")
        wait(wd, 10).until(lambda s: "Средняя цена продажи" in wd.find_element_by_xpath("//div[@class='reviews__price']").text)
        wd.find_element_by_xpath("//label[.='Весь каталог']").click()
        if wd.current_url != str(Baseurl.baseurl) + "catalog/video_13/videokameri-i-kamkorderi_128/":
            success = False
            print("verifyCurrentUrl failed")
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
Beispiel #3
0
class forsevascript(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_forsevascript(self):
        success = True
        wd = self.wd

        wd.find_element_by_link_text("add new").click()
        wd.find_element_by_name("theform").click()
        wd.find_element_by_name("firstname").click()
        wd.find_element_by_name("firstname").clear()
        wd.find_element_by_name("firstname").send_keys("123")
        wd.find_element_by_name("middlename").click()
        wd.find_element_by_name("middlename").clear()
        wd.find_element_by_name("middlename").send_keys("123")
        wd.find_element_by_name("lastname").click()
        wd.find_element_by_name("lastname").clear()
        wd.find_element_by_name("lastname").send_keys("123")
        wd.find_element_by_xpath("//div[@id='content']/form/input[21]").click()
        wd.find_element_by_link_text("home page").click()
        wd.find_element_by_link_text("Logout").click()
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
class save_calendar(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_save_calendar(self):
        success = True
        wd = self.wd
        wd.get("http://localhost/addressbook/")
        wd.find_element_by_name("user").click()
        wd.find_element_by_name("user").clear()
        wd.find_element_by_name("user").send_keys("admin")
        wd.find_element_by_id("LoginForm").click()
        wd.find_element_by_name("pass").click()
        wd.find_element_by_name("pass").clear()
        wd.find_element_by_name("pass").send_keys("secret")
        wd.find_element_by_xpath("//form[@id='LoginForm']/input[3]").click()
        wd.find_element_by_link_text("next birthdays").click()
        wd.find_element_by_link_text("map").click()
        wd.find_element_by_link_text("export").click()
        wd.find_element_by_xpath("//div[@id='content']/form[5]/input[2]").click()
        wd.find_element_by_link_text("Logout").click()
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
Beispiel #5
0
class UITestCase(LiveServerTestCase):
    def use_xvfb(self):
        from pyvirtualdisplay import Display
        self.display = Display('xvfb',
                               visible=1,
                               size=(1280, 1024))
        self.display.start()
        self.driver = WebDriver()

    def setUp(self):
        try:
            self.driver = WebDriver()
            ui_is_not_available = False
        except WebDriverException:
            ui_is_not_available = True

        if ui_is_not_available:
            self.use_xvfb()

        self.driver.implicitly_wait(10)
        super(UITestCase, self).setUp()

    def tearDown(self):
        self.driver.quit()
        if hasattr(self, 'display'):
            self.display.stop()

        super(UITestCase, self).tearDown()
Beispiel #6
0
class Application:

    def __init__(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(10)

        self.session = SessionHelper(self)
        self.group = GroupHelper(self)
        self.new_member = MemberHelper(self)

    def is_valid(self):
        try:
            self.wd.current_url
            return True
        except:
            return False


    def open_home_page(self):
        wd = self.wd
        wd.get("http://localhost/addressbook/addressbook/")
#        wd.get("http://localhost/addressbook/")



    def destroy(self):
        self.wd.quit()
Beispiel #7
0
class mentions(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_mentions(self):
        success = True
        wd = self.wd
        wd.get(str(Baseurl.baseurl) + "catalog/audio_17/mikrofoni_41/studijnie-mikrofoni_881/lentochnie_1069/product_14783_ntr")
        wd.find_element_by_css_selector("a.tabset__link.comments__count").click()
        if not ("Интересный микрофон! Давно его ждали" in wd.find_element_by_tag_name("html").text):
            success = False
            print("verifyTextPresent failed")
        if wd.find_element_by_id("add-review-link").text != "Оставьте свой отзыв":
            success = False
            print("verifyText failed")
        wd.find_element_by_id("add-review-link").click()
        wd.find_element_by_id("UserForm_email").click()
        wd.find_element_by_id("UserForm_email").clear()
        wd.find_element_by_id("UserForm_email").send_keys("*****@*****.**")
        wd.find_element_by_id("UserForm_password").click()
        wd.find_element_by_id("UserForm_password").clear()
        wd.find_element_by_id("UserForm_password").send_keys("11111")
        wd.find_element_by_id("submit_link").click()
        wd.find_element_by_css_selector("a.tabset__link.comments__count").click()
        if not (len(wd.find_elements_by_xpath("//div[@class='estimate__comment']")) != 0):
            success = False
            print("verifyElementPresent failed")
        if not (len(wd.find_elements_by_xpath("//div[@class='form__bottom']/button")) != 0):
            success = False
            print("verifyElementPresent failed")
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
class static_page_feedback(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_static_page_feedback(self):
        success = True
        wd = self.wd
        wd.get(str(Baseurl.baseurl))
        wd.find_element_by_xpath("//div[@class='ftr__nav']//a[.='Обратная связь']").click()
        if not (len(wd.find_elements_by_xpath("//div[@class='cnt']//h1[.='Связаться с нами']")) != 0):
            success = False
            print("verifyElementPresent failed")
        if not ("Если вы хотите предложить сотрудничество, сообщить о новости или теме для" in wd.find_element_by_tag_name("html").text):
            success = False
            print("verifyTextPresent failed")
        if not (len(wd.find_elements_by_id("Feedback_username")) != 0):
            success = False
            print("verifyElementPresent failed")
        if not (len(wd.find_elements_by_id("Feedback_contacts")) != 0):
            success = False
            print("verifyElementPresent failed")
        if not (len(wd.find_elements_by_id("Feedback_message")) != 0):
            success = False
            print("verifyElementPresent failed")
        if not (len(wd.find_elements_by_name("yt0")) != 0):
            success = False
            print("verifyElementPresent failed")
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
class test_add_group(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_add_group(self):
        wd = self.wd
class test_add_project(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_test_add_project(self):
        success = True
        wd = self.wd
        wd.get("http://localhost/mantisbt-1.2.19/login_page.php")
        wd.find_element_by_name("username").click()
        wd.find_element_by_name("username").clear()
        wd.find_element_by_name("username").send_keys("administrator")
        wd.find_element_by_name("password").click()
        wd.find_element_by_name("password").clear()
        wd.find_element_by_name("password").send_keys("root")
        wd.find_element_by_css_selector("input.button").click()
        wd.find_element_by_xpath("//table[@class='width75']//td[normalize-space(.)='']").click()
        wd.find_element_by_name("name").click()
        wd.find_element_by_name("name").clear()
        wd.find_element_by_name("name").send_keys("Project 1")
        wd.find_element_by_name("description").click()
        wd.find_element_by_name("description").clear()
        wd.find_element_by_name("description").send_keys("test")
        wd.find_element_by_css_selector("input.button").click()
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
class SimpleSelTest(unittest.TestCase):
    __test__ = False

    def setUp(self):
        self.caps['name'] = 'Selenium Testing'
        if (os.environ.get('TRAVIS')):
            self.caps['tunnel-identifier'] = os.environ['TRAVIS_JOB_NUMBER']
            self.caps['build'] = os.environ['TRAVIS_BUILD_NUMBER']
            self.caps['tags'] = [os.environ['TRAVIS_PYTHON_VERSION'], 'CI']
            self.username = os.environ['SAUCE_USERNAME']
            self.key = os.environ['SAUCE_ACCESS_KEY']
            hub_url = "%s:%s@localhost:4445" % (self.username, self.key)
            self.driver = webdriver.Remote(desired_capabilities=self.caps,
                                           command_executor="http://%s/wd/hub" % hub_url)
        else:
            self.driver = WebDriver()
        self.jobid = self.driver.session_id
        self.driver.implicitly_wait(60)
        print "Sauce Labs job: https://saucelabs.com/jobs/%s" % self.jobid

    def test_SimpleSelTest(self):
        success = True
        wd = self.driver
        wd.get("http://127.0.0.1:8080/")
        wd.find_element_by_link_text("Concept list").click()
        wd.find_element_by_link_text("Roadmap list").click()
        wd.find_element_by_link_text("Feedback/Questions").click()
        wd.find_element_by_link_text("About").click()
        wd.find_element_by_link_text("Sign in").click()
        wd.find_element_by_link_text("Sign up").click()
        self.assertTrue(success)

    def tearDown(self):
        self.driver.quit()
class event_displaying_properly(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_event_displaying_properly(self):
        success = True
        wd = self.wd
        wd.get(str(Baseurl.baseurl) + "events")
        if not (len(wd.find_elements_by_xpath("//div[@class='events']/div[1]//img")) != 0):
            success = False
            print("verifyElementPresent failed")
        if not (len(wd.find_elements_by_xpath("//div[@class='events']/div[1]//div[@class='event__ttl']")) != 0):
            success = False
            print("verifyElementPresent failed")
        if not (len(wd.find_elements_by_xpath("//div[@class='events']/div[1]//i[@class='ico ico_place']")) != 0):
            success = False
            print("verifyElementPresent failed")
        if not (len(wd.find_elements_by_xpath("//div[@class='events']/div[1]//span[@class='event__mark']")) != 0):
            success = False
            print("verifyElementPresent failed")
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
Beispiel #13
0
class delivery4(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_delivery4(self):
        success = True
        wd = self.wd
        wd.get("http://delivery.oorraa.com/")
        wd.find_element_by_id("from_city_name").click()
        wd.find_element_by_id("from_city_name").clear()
        wd.find_element_by_id("from_city_name").send_keys(u"Москва")
        wd.find_element_by_link_text(u"Москва, г. Москва").click()
        wd.find_element_by_id("to_city_name").click()
        wd.find_element_by_id("to_city_name").clear()
        wd.find_element_by_id("to_city_name").send_keys(u"Санкт-Петербург")
        wd.find_element_by_link_text(u"Санкт-Петербург, г. Санкт-Петербург").click()
        wd.find_element_by_id("gab_x").click()
        wd.find_element_by_id("gab_x").clear()
        wd.find_element_by_id("gab_x").send_keys("10")
        wd.find_element_by_id("gab_y").click()
        wd.find_element_by_id("gab_y").clear()
        wd.find_element_by_id("gab_y").send_keys("20")
        wd.find_element_by_id("gab_z").click()
        wd.find_element_by_id("gab_z").clear()
        wd.find_element_by_id("gab_z").send_keys("30")
        wd.find_element_by_id("weight").click()
        wd.find_element_by_id("weight").clear()
        wd.find_element_by_id("weight").send_keys("40")
        wd.find_element_by_css_selector("input.price_submit").click()
        wd.find_element_by_xpath("//div[@id='price_marker_container']/div[1]").click()
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
class catalog_join_company_create(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_catalog_join_company_create(self):
        success = True
        wd = self.wd
        wd.get(str(Baseurl.baseurl) + "catalog")
        wd.find_element_by_link_text("Присоединяйтесь").click()
        wd.find_element_by_id("registration_button").click()
        wd.find_element_by_link_text("Авторизоваться").click()
        wd.find_element_by_id("UserForm_email").click()
        wd.find_element_by_id("UserForm_email").clear()
        wd.find_element_by_id("UserForm_email").send_keys("*****@*****.**")
        wd.find_element_by_id("UserForm_password").click()
        wd.find_element_by_id("UserForm_password").clear()
        wd.find_element_by_id("UserForm_password").send_keys("11111")
        wd.find_element_by_id("submit_link").click()
        wd.find_element_by_link_text("Создать профиль").click()
        if wd.current_url != str(Baseurl.baseurl) + "company/create":
            success = False
            print("verifyCurrentUrl failed")
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
class Application:
    def __init__(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)

    def open_main_page(self):
        wd = self.wd
        wd.get("http://localhost/addressbook/index.php")

    def logout(self):
        wd = self.wd
        wd.find_element_by_link_text("Logout").click()

    def new_contact(self, data):
        wd = self.wd
        wd.find_element_by_link_text("add new").click()

    def login(self, username, password):
        wd = self.wd
        self.open_main_page()
        wd.find_element_by_name("user").click()
        wd.find_element_by_name("user").clear()
        wd.find_element_by_name("user").send_keys("%s" % username)
        wd.find_element_by_name("pass").click()
        wd.find_element_by_name("pass").clear()
        wd.find_element_by_name("pass").send_keys("%s" % password)
        wd.find_element_by_xpath("//form[@id='LoginForm']/input[3]").click()

    def destroy(self):
        self.wd.quit()
class test_add_group(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_test_add_group(self):
        success = True
        wd = self.wd
        wd.get("http://localhost/addressbook/")
        wd.find_element_by_name("user").click()
        wd.find_element_by_name("user").clear()
        wd.find_element_by_name("user").send_keys("admin")
        wd.find_element_by_id("LoginForm").click()
        wd.find_element_by_name("pass").click()
        wd.find_element_by_name("pass").clear()
        wd.find_element_by_name("pass").send_keys("secret")
        wd.find_element_by_css_selector("input[type=\"submit\"]").click()
        wd.find_element_by_link_text("groups").click()
        wd.find_element_by_name("new").click()
        wd.find_element_by_name("group_name").click()
        wd.find_element_by_name("group_name").clear()
        wd.find_element_by_name("group_name").send_keys("hghgf")
        wd.find_element_by_name("group_header").click()
        wd.find_element_by_name("group_header").clear()
        wd.find_element_by_name("group_header").send_keys("fghfgh")
        wd.find_element_by_name("group_footer").click()
        wd.find_element_by_name("group_footer").clear()
        wd.find_element_by_name("group_footer").send_keys("fghfghfghfd")
        wd.find_element_by_name("submit").click()
        wd.find_element_by_link_text("group page").click()
        wd.find_element_by_link_text("Logout").click()
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
class profile_wall_displayed_properly(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_profile_wall_displayed_properly(self):
        success = True
        wd = self.wd
        wd.get(str(Baseurl.baseurl))
        wd.find_element_by_link_text("Войти").click()
        wd.find_element_by_id("UserForm_email").click()
        wd.find_element_by_id("UserForm_email").clear()
        wd.find_element_by_id("UserForm_email").send_keys("*****@*****.**")
        wd.find_element_by_id("UserForm_password").click()
        wd.find_element_by_id("UserForm_password").clear()
        wd.find_element_by_id("UserForm_password").send_keys("1111")
        wd.find_element_by_id("submit_link").click()
        wd.find_element_by_xpath("//ul[@id='yw1']//strong[.=' Фотографии']").click()
        wd.find_element_by_xpath("//div[@class='btn__holder']//span[.='Добавить альбом']").click()
        wd.find_element_by_id("Album_name").click()
        wd.find_element_by_id("Album_name").clear()
        wd.find_element_by_id("Album_name").send_keys("New album")
        wd.find_element_by_id("Album_body").click()
        wd.find_element_by_id("Album_body").clear()
        wd.find_element_by_id("Album_body").send_keys("Sample description")
        wd.find_element_by_name("yt0").click()
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
class test_add_group(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_test_add_group(self):
        success = True
        wd = self.wd
        wd.get("http://*****:*****@id='LoginForm']/input[3]").click()
        wd.find_element_by_link_text("Группы").click()
        wd.find_element_by_name("new").click()
        wd.find_element_by_name("group_name").click()
        wd.find_element_by_name("group_name").clear()
        wd.find_element_by_name("group_name").send_keys("test_group")
        wd.find_element_by_name("submit").click()
        wd.find_element_by_link_text("Выйти").click()
        wd.find_element_by_name("pass").click()
        wd.find_element_by_name("pass").send_keys("\\undefined")
        wd.find_element_by_name("user").click()
        wd.find_element_by_name("user").clear()
        wd.find_element_by_name("user").send_keys("admin")
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
class placing_order_popup_present(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_placing_order_popup_present(self):
        success = True
        wd = self.wd
        wd.get(str(Baseurl.baseurl) + "catalog/video_13/videokameri-i-kamkorderi_128/xdcam_460/product_12700_pxw-x200")
        wd.find_element_by_link_text("Войти").click()
        wd.find_element_by_id("UserForm_email").click()
        wd.find_element_by_id("UserForm_email").clear()
        wd.find_element_by_id("UserForm_email").send_keys("*****@*****.**")
        wd.find_element_by_id("UserForm_password").click()
        wd.find_element_by_id("UserForm_password").clear()
        wd.find_element_by_id("UserForm_password").send_keys("11111")
        wd.find_element_by_id("submit_link").click()
        wd.find_element_by_link_text("Заказать").click()
        if not (len(wd.find_elements_by_xpath("//button[@class='submit-request metrika']")) != 0):
            success = False
            print("verifyElementPresent failed")
        if not (len(wd.find_elements_by_xpath("//button[@class='ui-button-cancel']")) != 0):
            success = False
            print("verifyElementPresent failed")
        wd.find_element_by_css_selector("button.submit-request.metrika").click()
        if not (len(wd.find_elements_by_id("request-success")) != 0):
            success = False
            print("verifyElementPresent failed")
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
class catalog_join_partner_request(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_(self):
        success = True
        wd = self.wd
        wd.get(str(Baseurl.baseurl) + "join")
        wd.find_element_by_link_text("Регистрация").click()
        wd.find_element_by_link_text("Авторизоваться").click()
        wd.find_element_by_id("UserForm_email").click()
        wd.find_element_by_id("UserForm_email").clear()
        wd.find_element_by_id("UserForm_email").send_keys("*****@*****.**")
        wd.find_element_by_id("UserForm_password").click()
        wd.find_element_by_id("UserForm_password").clear()
        wd.find_element_by_id("UserForm_password").send_keys("1111")
        wd.find_element_by_id("submit_link").click()
        wd.find_element_by_link_text("Отправить запрос").click()
        wd.find_element_by_css_selector("button.submit-request").click()
        if not (len(wd.find_elements_by_xpath("//div[@aria-describedby='request-success']")) != 0):
            success = False
            print("verifyElementPresent failed")
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
class profile_communities_displayed_properly(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_profile_communities_displayed_properly(self):
        success = True
        wd = self.wd
        wd.get(str(Baseurl.baseurl) + "login")
        wd.find_element_by_id("UserForm_email").click()
        wd.find_element_by_id("UserForm_email").clear()
        wd.find_element_by_id("UserForm_email").send_keys("*****@*****.**")
        wd.find_element_by_id("UserForm_password").click()
        wd.find_element_by_id("UserForm_password").clear()
        wd.find_element_by_id("UserForm_password").send_keys("1111")
        wd.find_element_by_id("submit_link").click()
        wd.find_element_by_xpath("//ul[@id='yw1']//strong[.=' Сообщества']").click()
        wd.find_element_by_link_text("Мои группы").click()
        if not ("Вы управляете 0 группами" in wd.find_element_by_tag_name("html").text):
            success = False
            print("verifyTextPresent failed")
        wd.find_element_by_link_text("Подписки").click()
        if not ("Вы состоите в 0 группах" in wd.find_element_by_tag_name("html").text):
            success = False
            print("verifyTextPresent failed")
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
Beispiel #22
0
class test_santon(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_test_santon(self):
        success = True
        wd = self.wd
        wd.get("http://santehnika-online.ru/")
        wd.find_element_by_link_text("Акриловые ванны").click()
        wd.find_element_by_css_selector("img[alt=\"Акриловая ванна Serena Classic (170 см)\"]").click()
        wd.find_element_by_css_selector("#cmplproduct88078 > div.block_option > label.switch > span.switch").click()
        wd.find_element_by_id("linked_9_88078").click()
        wd.find_element_by_css_selector("#cmplproduct533850 > div.block_option > label.switch > span.switch").click()
        wd.find_element_by_id("linked_11_533850").click()
        wd.find_element_by_link_text("Акриловые ванны").click()
        wd.find_element_by_css_selector("img[alt=\"Акриловая ванна Aquanet Nord (170 см)\"]").click()
        wd.find_element_by_css_selector("span.switch").click()
        if not wd.find_element_by_id("linked_1_33825").is_selected():
            wd.find_element_by_id("linked_1_33825").click()
        wd.find_element_by_xpath("//div[@class='borgray']/div[1]/div[2]/input").click()
        wd.find_element_by_id("simplemodal-overlay").click()
        wd.find_element_by_css_selector("div.owl-wrapper-outer").click()
        wd.find_element_by_css_selector("#floating_form_cart > div.ofzakinput > input.yellow").click()
        wd.find_element_by_id("NEW_LOGIN").click()
        wd.find_element_by_id("NEW_LOGIN").clear()
        wd.find_element_by_id("NEW_LOGIN").send_keys("+7 (977) 777-77-71")
        wd.find_element_by_id("NEW_EMAIL").click()
        wd.find_element_by_id("NEW_EMAIL").clear()
        wd.find_element_by_id("NEW_EMAIL").send_keys("*****@*****.**")
        wd.find_element_by_id("order_ajax_button").click()
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
Beispiel #23
0
class add_group(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_add_group(self):
        success = True
        wd = self.wd
        wd.get("http://localhost/addressbook/")
        wd.find_element_by_name("pass").click()
        wd.find_element_by_name("user").send_keys("admin")
        wd.find_element_by_id("LoginForm").click()
        wd.find_element_by_name("pass").click()
        wd.find_element_by_name("pass").send_keys("secret")
        wd.find_element_by_xpath("//form[@id='LoginForm']/input[3]").click()
        wd.find_element_by_link_text("groups").click()
        wd.find_element_by_name("new").click()
        wd.find_element_by_name("group_name").click()
        wd.find_element_by_name("group_name").clear()
        wd.find_element_by_name("group_name").send_keys("123ee")
        wd.find_element_by_name("group_header").click()
        wd.find_element_by_name("group_header").clear()
        wd.find_element_by_name("group_header").send_keys("awdfafdsfsdsf")
        wd.find_element_by_name("group_footer").click()
        wd.find_element_by_name("group_footer").clear()
        wd.find_element_by_name("group_footer").send_keys("dfsdfsdfdsfsdf")
        wd.find_element_by_name("submit").click()
        wd.find_element_by_link_text("groups").click()
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
class vacancy_create_and_edit(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_vacancy_create_and_edit(self):
        success = True
        wd = self.wd
        wd.get(str(Baseurl.baseurl) + "resume")
        wd.find_element_by_link_text("Разместить вакансию").click()
        wd.find_element_by_id("UserForm_email").click()
        wd.find_element_by_id("UserForm_email").clear()
        wd.find_element_by_id("UserForm_email").send_keys("*****@*****.**")
        wd.find_element_by_id("UserForm_password").click()
        wd.find_element_by_id("UserForm_password").clear()
        wd.find_element_by_id("UserForm_password").send_keys("1111")
        wd.find_element_by_id("submit_link").click()
        wd.find_element_by_id("Vacancy_name").click()
        wd.find_element_by_id("Vacancy_name").clear()
        wd.find_element_by_id("Vacancy_name").send_keys("Создание вакансии")
        if not wd.find_element_by_id("select2-drop-mask").is_selected():
            wd.find_element_by_id("select2-drop-mask").click()
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
Beispiel #25
0
class add_group(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)

    def go_home_page(self, wd):
        wd.get("http://localhost/addressbook/")

    def login(self, wd, username, password):
        self.go_home_page(wd)
        wd.find_element_by_name("user").click()
        wd.find_element_by_name("user").clear()
        wd.find_element_by_name("user").send_keys(username)
        wd.find_element_by_name("pass").click()
        wd.find_element_by_name("pass").clear()
        wd.find_element_by_name("pass").send_keys(password)
        wd.find_element_by_css_selector("input[type=\"submit\"]").click()

    def go_to_groups_page(self, wd):
        wd.find_element_by_link_text("groups").click()

    def add_new_group(self, wd, g_name, g_header, g_footer):
        self.go_to_groups_page(wd)
        wd.find_element_by_name("new").click()
        wd.find_element_by_name("group_name").click()
        wd.find_element_by_name("group_name").clear()
        wd.find_element_by_name("group_name").send_keys(g_name)
        wd.find_element_by_css_selector("#content > form").click()
        wd.find_element_by_name("group_header").click()
        wd.find_element_by_name("group_header").clear()
        wd.find_element_by_name("group_header").send_keys(g_header)
        wd.find_element_by_name("group_footer").click()
        wd.find_element_by_name("group_footer").clear()
        wd.find_element_by_name("group_footer").send_keys(g_footer)
        wd.find_element_by_name("submit").click()
        self.go_to_groups_page(wd)

    def logout(self, wd):
        self.click_on_home(wd)
        wd.find_element_by_link_text("Logout").click()

    def click_on_home(self, wd):
        wd.find_element_by_link_text("home").click()

    def test_add_group(self):
        wd = self.wd
        self.login(wd, username = "******",password = "******")
        self.add_new_group(wd, g_name="test", g_header="test", g_footer="foot")
        self.logout(wd)


    def test_add_empty_group(self):
        wd = self.wd
        self.login(wd, username = "******",password = "******")
        self.add_new_group(wd, g_name="", g_header="", g_footer="")
        self.logout(wd)

    
    def tearDown(self):
        self.wd.quit()
class testPresenceOfContactInfoPage(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_testPresenceOfContactInfoPage(self):
        success = True
        wd = self.wd
        wd.get("https://www.homejoy.com/")
        if not ("Get Your Place Cleaned" in wd.find_element_by_tag_name("html").text):
            success = False
            print("verifyTextPresent failed")
        wd.find_element_by_link_text("BOOK APPOINTMENT").click()
        if not ("Number of hours to book" in wd.find_element_by_tag_name("html").text):
            success = False
            print("verifyTextPresent failed")
        if not wd.find_element_by_xpath("//form[@id='home-size-form']/div/div[1]/select//option[3]").is_selected():
            wd.find_element_by_xpath("//form[@id='home-size-form']/div/div[1]/select//option[3]").click()
        if not ("100% Satisfaction Guarantee" in wd.find_element_by_tag_name("html").text):
            success = False
            print("verifyTextPresent failed")
        wd.find_element_by_xpath("//div[@id='info-pane-person']//button[.='Next']").click()
        if not ("Enter Contact Info" in wd.find_element_by_tag_name("html").text):
            success = False
            print("verifyTextPresent failed")
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
Beispiel #27
0
class Application:

    def __init__(self):
        # контруктор, который инициализирует ссылку на драйвер и на помощников
        self.wd = WebDriver()
        self.session = SessionHelper(self)
        self.group = GroupHelper(self)
        self.contact = ContactHelper(self)

    def is_valid(self):
        try:
            #какой адрес страницы
            self.wd.current_url
            return True
        except:
            return False

    def open_home_page(self):
        # навигация
        wd = self.wd
        wd.get("http://localhost/addressbook/")

    def destroy(self):
        # метод разрушает фикстуру
        self.wd.quit()
Beispiel #28
0
class companies_navigation(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)

    def test_companies_navigation(self):
        success = True
        wd = self.wd
        wd.get(str(Baseurl.baseurl))
        wd.find_element_by_link_text("Компании").click()
        if wd.find_element_by_css_selector("h1.cnt__ttl").text != "Компании":
            success = False
            print("verifyText failed")
        if wd.find_element_by_css_selector("b").text != "Поиск по категориям":
            success = False
            print("verifyText failed")
        if wd.find_element_by_xpath("//div[@class='cnt']//b[.='Новые компании']").text != "Новые компании":
            success = False
            print("verifyText failed")
        if wd.find_element_by_css_selector("p.news_title > b").text != "Новости компаний":
            success = False
            print("verifyText failed")
        wd.find_element_by_id("keywords").click()
        wd.find_element_by_id("keywords").clear()
        wd.find_element_by_id("keywords").send_keys("ООО Корпорация DNK")
        wd.find_element_by_id("filter-by-keywords").click()
        wd.find_element_by_link_text("ООО Корпорация DNK").click()
        self.assertTrue(success)

    def tearDown(self):
        self.wd.quit()
Beispiel #29
0
class reg_mail(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_reg_mail(self):
        success = True
        wd = self.wd
        wd.get("http://php7-test.tvkinoradio.ru/")
        wd.find_element_by_link_text("Регистрация").click()
        wd.find_element_by_id("UserForm_first_name").click()
        wd.find_element_by_id("UserForm_first_name").clear()
        wd.find_element_by_id("UserForm_first_name").send_keys("Sergey")
        wd.find_element_by_id("UserForm_last_name").click()
        wd.find_element_by_id("UserForm_last_name").clear()
        wd.find_element_by_id("UserForm_last_name").send_keys("Test")
        wd.find_element_by_id("UserForm_email").click()
        wd.find_element_by_id("UserForm_email").clear()
        wd.find_element_by_id("UserForm_email").send_keys("*****@*****.**")
        wd.find_element_by_id("UserForm_password").click()
        wd.find_element_by_id("UserForm_password").clear()
        wd.find_element_by_id("UserForm_password").send_keys("12345")
        wd.find_element_by_id("UserForm_verifyPassword").click()
        wd.find_element_by_id("UserForm_verifyPassword").clear()
        wd.find_element_by_id("UserForm_verifyPassword").send_keys("12345")
        wd.find_element_by_xpath("//form[@id='yw1']/div[7]/input").click()
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
class single_event_displayed_properly(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_single_event_displayed_properly(self):
        success = True
        wd = self.wd
        wd.get(str(Baseurl.baseurl) + "events")
        wd.find_element_by_css_selector("div.event__ttl > a").click()
        if not (len(wd.find_elements_by_xpath("//div[@class='post__img']/a/img")) != 0):
            success = False
            print("verifyElementPresent failed")
        if not (len(wd.find_elements_by_xpath("//li[@class='post__entry_date']/p[1]")) != 0):
            success = False
            print("verifyElementPresent failed")
        if not (len(wd.find_elements_by_xpath("//li[@class='post__entry_date']/p[2]")) != 0):
            success = False
            print("verifyElementPresent failed")
        if not (len(wd.find_elements_by_id("join_link")) != 0):
            success = False
            print("verifyElementPresent failed")
        if not (len(wd.find_elements_by_css_selector("li.post__entry_address > p")) != 0):
            success = False
            print("verifyElementPresent failed")
        if not (len(wd.find_elements_by_css_selector("div.post__info.line")) != 0):
            success = False
            print("verifyElementPresent failed")
        if not (len(wd.find_elements_by_css_selector("h3.post__section-ttl")) != 0):
            success = False
            print("verifyElementPresent failed")
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()
 def setUp(self):
     self.wd = WebDriver(
         firefox_binary="c:/Program Files/Mozilla Firefox/firefox.exe")
     self.wd.implicitly_wait(5)
Beispiel #32
0
class UITestCase(LiveServerTestCase):
    def use_xvfb(self):
        from pyvirtualdisplay import Display
        self.display = Display('xvfb', visible=1, size=(1280, 1024))
        self.display.start()
        self.driver = WebDriver()

    def setUp(self):
        try:
            self.driver = WebDriver()
            ui_is_not_available = False
        except WebDriverException:
            ui_is_not_available = True

        if ui_is_not_available:
            self.use_xvfb()

        self.driver.implicitly_wait(10)
        super(UITestCase, self).setUp()

    def tearDown(self):
        self.driver.quit()
        if hasattr(self, 'display'):
            self.display.stop()

        # I believe this line is no longer necessary, but I'm leaving it here
        # until the UI tests have run many times without deadlocking.
        # -RM 20140522
        #self.kill_pending_transactions()

        super(UITestCase, self).tearDown()

    def kill_pending_transactions(self):
        # The super.tearDown sometimes hangs when truncating tables
        # because of lingering pending transactions with locks on those tables.
        # Kill them to avoid deadlock!
        try:
            dbname = settings.DATABASES['default']['NAME']
            sql = "select pg_terminate_backend(procpid)" + \
                " from pg_stat_activity where datname='%s'" % dbname + \
                " and current_query='<IDLE> in transaction';"
            connection.cursor().execute(sql)
        except InterfaceError:
            # Sometimes we get "connection already closed"
            pass

    def click(self, selector):
        self.find(selector).click()

    def click_when_visible(self, selector):
        element = self.find(selector)
        self.wait_until_visible(element)
        element.click()

    def find(self, selector):
        return self.driver.find_element_by_css_selector(selector)

    def find_name(self, name):
        return self.driver.find_element_by_name(name)

    def find_id(self, id):
        return self.driver.find_element_by_id(id)

    def process_login_form(self, username, password):
        username_elmt = self.wait_until_present('[name="username"]')
        password_elmt = self.find_name('password')

        username_elmt.send_keys(username)
        password_elmt.send_keys(password)

        self.click('form * button')

    def browse_to_url(self, url):
        self.driver.get(self.live_server_url + url)

    def find_anchor_by_url(self, url):
        return self.find("[href='%s']" % url)

    def wait_until_present(self, selector, timeout=10):
        """
        Wait until an element with CSS 'selector' exists on the page.
        Useful for detecting that an operation loads the page you're expecting.
        """
        element = [None]  # use list so it can be set by inner scope

        def is_present(driver):
            element[0] = self.find(selector)
            return element[0] is not None

        WebDriverWait(self.driver, timeout).until(is_present)
        return element[0]

    def wait_until_text_present(self, text, timeout=10):
        """
        Wait until 'text' exists on the page.
        Useful for detecting that an operation loads the page you're expecting.
        """
        WebDriverWait(self.driver,
                      timeout).until(lambda driver: text in driver.page_source)

    def wait_until_enabled(self, element_or_selector, timeout=10):
        """
        Wait until 'element_or_selector' is enabled.
        """
        element = self._get_element(element_or_selector)
        WebDriverWait(self.driver, timeout).until(
            lambda driver: element.get_attribute("disabled") is None)
        return element

    def wait_until_visible(self, element_or_selector, timeout=10):
        """
        Wait until 'element_or_selector' (known to already exist on the page)
        is displayed.
        """
        element = self._get_element(element_or_selector)
        WebDriverWait(self.driver,
                      timeout).until(lambda driver: element.is_displayed())
        return element

    def wait_until_invisible(self, element_or_selector, timeout=10):
        """
        Wait until 'element_or_selector' (known to already exist on the page)
        is not displayed.
        """
        element = self._get_element(element_or_selector)

        def is_invisible(driver):
            try:
                return not element.is_displayed()
            except StaleElementReferenceException:
                return True

        WebDriverWait(self.driver, timeout).until(is_invisible)
        return element

    def _get_element(self, element_or_selector):
        if isinstance(element_or_selector, basestring):
            return self.find(element_or_selector)
        else:
            return element_or_selector
Beispiel #33
0
    def setUpClass(cls):
        super().setUpClass()
        cls.options = Options()
        cls.options.add_argument("--headless")
        cls.selenium = WebDriver(firefox_options=cls.options)
        cls.selenium.implicitly_wait(10)

        categories = [
            {
                "products": 32107,
                "name": "Aliments et boissons à base de végétaux",
                "url": "https://fr.openfoodfacts.org/categorie/aliments-et-boissons-a-base-de-vegetaux",
                "id": "en:plant-based-foods-and-beverages"
            },
            {
                "id": "en:plant-based-foods",
                "url": "https://fr.openfoodfacts.org/categorie/aliments-d-origine-vegetale",
                "products": 27435,
                "name": "Aliments d'origine végétale"
            },
            {
                "products": 21875,
                "name": "Boissons",
                "url": "https://fr.openfoodfacts.org/categorie/boissons",
                "sameAs": [
                    "https://www.wikidata.org/wiki/Q40050"
                ],
                "id": "en:beverages"
            },
            {
                "url": "https://fr.openfoodfacts.org/categorie/boissons-non-sucrees",
                "name": "Boissons non sucrées",
                "products": 9153,
                "id": "en:non-sugared-beverages"
            },
            {
                "products": 8006,
                "name": "Produits fermentés",
                "url": "https://fr.openfoodfacts.org/categorie/produits-fermentes",
                "id": "en:fermented-foods"
            },
            {
                "id": "en:fermented-milk-products",
                "sameAs": [
                    "https://www.wikidata.org/wiki/Q3506176"
                ],
                "products": 8002,
                "name": "Produits laitiers fermentés",
                "url": "https://fr.openfoodfacts.org/categorie/produits-laitiers-fermentes"
            },
            {
                "id": "en:non-alcoholic-beverages",
                "url": "https://fr.openfoodfacts.org/categorie/boissons-sans-alcool",
                "products": 7646,
                "name": "Boissons sans alcool"
            },
            {
                "url": "https://fr.openfoodfacts.org/categorie/biscuits-et-gateaux",
                "products": 7294,
                "name": "Biscuits et gâteaux",
                "id": "en:biscuits-and-cakes"
            },
            {
                "id": "en:meats",
                "products": 7191,
                "name": "Viandes",
                "url": "https://fr.openfoodfacts.org/categorie/viandes"
            },
            {
                "id": "en:spreads",
                "url": "https://fr.openfoodfacts.org/categorie/produits-a-tartiner",
                "products": 6724,
                "name": "Produits à tartiner"
            },
        ]

        products = [
            {
                "product_name_fr": "Le jus de raisin 100% jus de fruits",
                "code": "123456789",
                "image_url":"https://static.openfoodfacts.org/images/products/609/109/100/0301/front_fr.13.100.jpg",
                "nutrition_grade_fr": "a",
                "generic_name_fr" : "jus de fruit naturel sans sucre ajouté",
                "categories_hierarchy": [
                    "en:plant-based-foods-and-beverages",
                    "en:beverages",
                ],
            },
            {
                "product_name_fr": "Le haricot 100% naturellement bleue",
                "code": "987654321",
                "image_url": "https://static.openfoodfacts.org/images/products/152/haricot.jpg",
                "nutrition_grade_fr": "b",
                "generic_name_fr" : "",
                "categories_hierarchy": [
                    "en:plant-based-foods",
                ],
            },
            {
                "product_name_fr": "cola à la mousse de bière",
                "code": "456789123",
                "image_url": "https://static.openfoodfacts.org/images/products/152/on-en-reve-tous.jpg",
                "nutrition_grade_fr": "d",
                "generic_name_fr" : "du coca et de la bière, ca mousse pas mal",
                "categories_hierarchy": [
                    "en:beverages",
                    "en:plant-based-foods-and-beverages",
                ],
            },
            {
                "product_name_fr": "Banane à la feuille de coca",
                "code": "12345787459",
                "image_url":"https://static.openfoodfacts.org/images/products/609/109/100/0301/front_fr.13.100.jpg",
                "nutrition_grade_fr": "a",
                "generic_name_fr": "",
                "categories_hierarchy": [
                    "en:plant-based-foods-and-beverages",
                    "en:beverages",
                    "en:biscuits-and-cakes"
                ],
            },
            {
                "product_name_fr": "steack charal",
                "code": "987695121",
                "image_url": "https://static.openfoodfacts.org/images/products/152/haricot.jpg",
                "generic_name_fr":"mmmmmmhhhh Charal!!",
                "nutrition_grade_fr": "a",
                "categories_hierarchy": [
                    "en:meats",
                ],
            },
            {
                "product_name_fr": "nutella plein d'huiles de palme",
                "code": "4567859631223",
                "image_url": "https://static.openfoodfacts.org/images/products/152/on-en-reve-tous.jpg",
                "nutrition_grade_fr": "a",
                "generic_name_fr": "pas bon pour les singes et les artères",
                "categories_hierarchy": [
                    "en:spreads",
                ],
            },
            {
                "product_name_fr": "steack de fausses viandes",
                "code": "987751251",
                "image_url": "https://static.openfoodfacts.org/images/products/152/haricot.jpg",
                "nutrition_grade_fr": "a",
                "generic_name_fr": "ca a le gout de viande, mais c'est pas de la viande",
                "categories_hierarchy": [
                    "en:meats",
                ],
            },
            {
                "product_name_fr": "lait demi-écrémé pour une meilleure digestion",
                "code": "474369523",
                "image_url": "https://static.openfoodfacts.org/images/products/152/on-en-reve-tous.jpg",
                "nutrition_grade_fr": "a",
                "generic_name_fr": "lait de vache frais",
                "categories_hierarchy": [
                    "en:non-alcoholic-beverages",
                    "en:fermented-milk-products"
                ],
            },
        ]

        for category in categories:
            Category.objects.create(name=category["name"].lower(),
                                    api_id=category["id"].lower(),
                                    total_products=category["products"],
                                    enough_good_nutriscore=True)

        for product in products:
            new_product = Product.objects.create(name=product["product_name_fr"].lower(),
                                   ref=product["code"],
                                   nutriscore=product["nutrition_grade_fr"],
                                   picture=product["image_url"],
                                   description=product["generic_name_fr"])
            
            for category in product["categories_hierarchy"]:
                try:
                    cat_in_db = Category.objects.get(api_id=category) 
                    new_product.categories.add(cat_in_db)
                except:
                    pass

        # # We create a first user which registered one product
        username = '******'
        mail = '*****@*****.**'
        password = '******'
        password_check = 'test-login-selenium'
        user = User.objects.create_superuser(username, mail, password)
        user_profile = Profile(user=user)
        user_profile.save()
        product = Product.objects.get(ref="123456789")
        user_profile.products.add(product.id)
Beispiel #34
0
# -*- coding: utf-8 -*-
from selenium.webdriver.firefox.webdriver import WebDriver
from selenium.webdriver.common.action_chains import ActionChains
import time

success = True
wd = WebDriver()
wd.implicitly_wait(60)


def is_alert_present(wd):
    try:
        wd.switch_to_alert().text
        return True
    except:
        return False


try:
    wd.get("http://kv-mmc-ais01.mts.com.ua:4450/")
    wd.find_element_by_id("tbUserName").click()
    wd.find_element_by_id("tbUserName").clear()
    wd.find_element_by_id("tbUserName").send_keys("akarpenchuk")
    wd.find_element_by_id("tbPassword").click()
    wd.find_element_by_id("tbPassword").clear()
    wd.find_element_by_id("tbPassword").send_keys("")
    wd.find_element_by_id("btnLogin").click()
    wd.find_element_by_xpath(
        "//div[@id='zz14_TopNavigationMenuV4']//span[.='ЦКУ']").click()
    wd.find_element_by_xpath(
        "//div[@id='zz15_V4QuickLaunchMenu']/div/ul/li[2]/a/span/span").click(
Beispiel #35
0
class FieldPrintingTest(LiveServerTestCase):
    """
    Testing TagFields objects printing functions
    """
    def setUp(self):
        self.mymetadata = TestMetadata()
        self.mymetadata.view_name = 'template_test'
        self.mymetadata.title = TitleTag(tag_value='Title Test')
        self.mymetadata.author = MetaTag(meta_name='author',
                                         meta_content='Test Author')
        self.mymetadata.description = MetaTag(meta_name='description',
                                              meta_content='Test Description')
        self.mymetadata.keywords = KeywordsTag(meta_name='keywords',
                                               meta_content='test, author')
        # Attr name and class attribute name are not equals, let's do it by setattr
        setattr(self.mymetadata, 'og:title', MetaTag(meta_name='og:title'))
        setattr(self.mymetadata, 'twitter:title',
                MetaTag(meta_name='twitter:title'))
        setattr(self.mymetadata, 'og:description',
                MetaTag(meta_name='og:description'))
        setattr(self.mymetadata, 'twitter:description',
                MetaTag(meta_name='twitter:description'))
        setattr(
            self.mymetadata, 'og:url',
            MetaTag(meta_name='og:url', meta_content='http://infantium.com'))
        setattr(self.mymetadata, 'twitter:url',
                MetaTag(meta_name='twitter:url'))
        setattr(self.mymetadata, 'og:type',
                MetaTag(meta_name='og:type', meta_content='type'))
        setattr(self.mymetadata, 'twitter:card',
                MetaTag(meta_name='twitter:card', meta_content='card'))
        setattr(
            self.mymetadata, 'og:image',
            ImageMetaTag(meta_name='og:image',
                         meta_content='img/partners/animation2/base.png'))
        setattr(self.mymetadata, 'twitter:image',
                ImageMetaTag(meta_name='twitter:image'))

        self.mymetadata.save()

        self.firefox = FirefoxDriver()

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

    def test_title_rendering(self):
        self.firefox.get('%s%s' % (self.live_server_url, '/test/'))
        title_element = self.firefox.title
        self.assertIsNotNone(title_element)
        self.assertEqual(title_element, 'Title Test')

    def test_metatags_rendering(self):
        self.firefox.get('%s%s' % (self.live_server_url, '/test/'))

        author_element = self.firefox.find_element_by_xpath(
            '/html/head/meta[@name=\'author\']')
        self.assertIsNotNone(author_element)
        self.assertEqual(author_element.get_attribute('content'),
                         'Test Author')

        description_element = self.firefox.find_element_by_xpath(
            '/html/head/meta[@name=\'description\']')
        self.assertIsNotNone(description_element)
        self.assertEqual(description_element.get_attribute('content'),
                         'Test Description')

        keywords_element = self.firefox.find_element_by_xpath(
            '/html/head/meta[@name=\'keywords\']')
        self.assertIsNotNone(keywords_element)
        self.assertEqual(keywords_element.get_attribute('content'),
                         'test, author')

        og_title_element = self.firefox.find_element_by_xpath(
            '/html/head/meta[@name=\'og:title\']')
        self.assertIsNotNone(og_title_element)
        self.assertEqual(og_title_element.get_attribute('content'),
                         self.firefox.title)  # Should be equal to titleTag
        twitter_title_element = self.firefox.find_element_by_xpath(
            '/html/head/meta[@name=\'twitter:title\']')
        self.assertIsNotNone(twitter_title_element)
        self.assertEqual(twitter_title_element.get_attribute('content'),
                         og_title_element.get_attribute('content'))

        og_description_element = self.firefox.find_element_by_xpath(
            '/html/head/meta[@name=\'og:description\']')
        self.assertIsNotNone(og_description_element)
        self.assertEqual(og_description_element.get_attribute('content'),
                         description_element.get_attribute('content'))
        twitter_description_element = self.firefox.find_element_by_xpath(
            '/html/head/meta[@name=\'twitter:description\']')
        self.assertIsNotNone(twitter_description_element)
        self.assertEqual(twitter_description_element.get_attribute('content'),
                         og_description_element.get_attribute('content'))

        og_url_element = self.firefox.find_element_by_xpath(
            '/html/head/meta[@name=\'og:url\']')
        self.assertIsNotNone(og_url_element)
        self.assertEqual(og_url_element.get_attribute('content'),
                         'http://infantium.com')
        twitter_url_element = self.firefox.find_element_by_xpath(
            '/html/head/meta[@name=\'twitter:url\']')
        self.assertIsNotNone(twitter_url_element)
        self.assertEqual(twitter_url_element.get_attribute('content'),
                         og_url_element.get_attribute('content'))

        og_image_element = self.firefox.find_element_by_xpath(
            '/html/head/meta[@name=\'og:image\']')
        self.assertIsNotNone(og_image_element)
        self.assertEqual(og_image_element.get_attribute('content'),
                         '/static/img/partners/animation2/base.png')
        twitter_image_element = self.firefox.find_element_by_xpath(
            '/html/head/meta[@name=\'twitter:image\']')
        self.assertIsNotNone(twitter_image_element)
        self.assertEqual(twitter_image_element.get_attribute('content'),
                         og_image_element.get_attribute('content'))
Beispiel #36
0
 def setUpClass(cls):
     cls.selenium = WebDriver(
         executable_path=
         r'C:\Users\Jacqueline\Documents\Cmput 401\geckodriver.exe')
     cls.selenium.implicitly_wait(5)
     super(SeleniumTest, cls).setUpClass()
 def setUpClass(cls):
     cls.selenium = WebDriver()
     super(HelloIntegrationTests, cls).setUpClass()
Beispiel #38
0
 def setUp(self):
     self.url = "{}{}".format(self.live_server_url, reverse('core:index'))
     self.driver = WebDriver()
     self.driver.implicitly_wait(5)
Beispiel #39
0
 def setUpClass(cls):
     cls.selenium = WebDriver()
     super(SeleniumTestCase, cls).setUpClass()
class AddGroup(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver(
            firefox_binary="c:/Program Files/Mozilla Firefox/firefox.exe")
        self.wd.implicitly_wait(5)

    def test_add_group(self):
        wd = self.wd
        self.open_homepage(wd)
        self.login(wd, username="******", password="******")
        self.open_group_page(wd)
        self.create_group(wd,
                          name="test_group",
                          header="group_header",
                          footer="group_footer")
        self.return_to_group_page(wd)
        self.logout(wd)

    def test_add_empty_group(self):
        wd = self.wd
        self.open_homepage(wd)
        self.login(wd, username="******", password="******")
        self.open_group_page(wd)
        self.create_group(wd, name="", header="", footer="")
        self.return_to_group_page(wd)
        self.logout(wd)

    def logout(self, wd):
        wd.find_element_by_link_text("LOGOUT").click()

    def return_to_group_page(self, wd):
        wd.find_element_by_link_text("GROUPS").click()

    def create_group(self, wd, name, header, footer):
        # init group creation
        wd.find_element_by_name("new").click()
        # fill group form
        wd.find_element_by_name("group_name").click()
        wd.find_element_by_name("group_name").clear()
        wd.find_element_by_name("group_name").send_keys(name)
        wd.find_element_by_name("group_header").click()
        wd.find_element_by_name("group_header").clear()
        wd.find_element_by_name("group_header").send_keys(header)
        wd.find_element_by_name("group_footer").click()
        wd.find_element_by_name("group_footer").clear()
        wd.find_element_by_name("group_footer").send_keys(footer)
        # submit creation
        wd.find_element_by_name("submit").click()

    def open_group_page(self, wd):
        wd.find_element_by_link_text("GROUPS").click()

    def open_homepage(self, wd):
        wd.get("http://localhost/addressbook/")

    def login(self, wd, username, password):
        wd.find_element_by_name("user").click()
        wd.find_element_by_name("user").clear()
        wd.find_element_by_name("user").send_keys(username)
        wd.find_element_by_name("pass").click()
        wd.find_element_by_name("pass").clear()
        wd.find_element_by_name("pass").send_keys(password)
        wd.find_element_by_xpath("//form[@id='LoginForm']/input[3]").click()

    def tearDown(self):
        self.wd.quit()
Beispiel #41
0
class cont(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)

    def test_cont(self):
        success = True
        wd = self.wd
        wd.get("http://localhost/addressbook/edit.php")
        wd.find_element_by_name("user").click()
        wd.find_element_by_name("user").clear()
        wd.find_element_by_name("user").send_keys("admin")
        wd.find_element_by_name("pass").click()
        wd.find_element_by_name("pass").clear()
        wd.find_element_by_name("pass").send_keys("secret")
        wd.find_element_by_xpath("//form[@id='LoginForm']/input[3]").click()
        wd.find_element_by_name("firstname").click()
        wd.find_element_by_link_text("add new").click()
        wd.find_element_by_name("firstname").click()
        wd.find_element_by_name("firstname").clear()
        wd.find_element_by_name("firstname").send_keys("123")
        wd.find_element_by_name("middlename").click()
        wd.find_element_by_name("middlename").clear()
        wd.find_element_by_name("middlename").send_keys("123")
        wd.find_element_by_name("lastname").click()
        wd.find_element_by_name("lastname").clear()
        wd.find_element_by_name("lastname").send_keys("123")
        wd.find_element_by_name("nickname").click()
        wd.find_element_by_name("nickname").clear()
        wd.find_element_by_name("nickname").send_keys("123")
        wd.find_element_by_name("title").click()
        wd.find_element_by_name("title").clear()
        wd.find_element_by_name("title").send_keys("123")
        wd.find_element_by_name("company").click()
        wd.find_element_by_name("company").clear()
        wd.find_element_by_name("company").send_keys("123")
        wd.find_element_by_name("address").click()
        wd.find_element_by_name("address").clear()
        wd.find_element_by_name("address").send_keys("133")
        wd.find_element_by_name("home").click()
        wd.find_element_by_name("home").clear()
        wd.find_element_by_name("home").send_keys("123")
        wd.find_element_by_name("mobile").click()
        wd.find_element_by_name("mobile").clear()
        wd.find_element_by_name("mobile").send_keys("123")
        wd.find_element_by_name("work").click()
        wd.find_element_by_name("work").clear()
        wd.find_element_by_name("work").send_keys("123")
        wd.find_element_by_name("fax").click()
        wd.find_element_by_name("fax").clear()
        wd.find_element_by_name("fax").send_keys("123")
        wd.find_element_by_name("email").click()
        wd.find_element_by_name("email").send_keys("\\9")
        wd.find_element_by_name("email2").click()
        wd.find_element_by_name("email2").clear()
        wd.find_element_by_name("email2").send_keys("123")
        wd.find_element_by_name("email3").click()
        wd.find_element_by_name("email3").clear()
        wd.find_element_by_name("email3").send_keys("123")
        wd.find_element_by_name("homepage").click()
        wd.find_element_by_name("homepage").clear()
        wd.find_element_by_name("homepage").send_keys("123")
        if not wd.find_element_by_xpath(
                "//div[@id='content']/form/select[1]//option[1]").is_selected(
                ):
            wd.find_element_by_xpath(
                "//div[@id='content']/form/select[1]//option[1]").click()
        if not wd.find_element_by_xpath(
                "//div[@id='content']/form/select[1]//option[14]").is_selected(
                ):
            wd.find_element_by_xpath(
                "//div[@id='content']/form/select[1]//option[14]").click()
        if not wd.find_element_by_xpath(
                "//div[@id='content']/form/select[1]//option[14]").is_selected(
                ):
            wd.find_element_by_xpath(
                "//div[@id='content']/form/select[1]//option[14]").click()
        if not wd.find_element_by_xpath(
                "//div[@id='content']/form/select[1]//option[14]").is_selected(
                ):
            wd.find_element_by_xpath(
                "//div[@id='content']/form/select[1]//option[14]").click()
        if not wd.find_element_by_xpath(
                "//div[@id='content']/form/select[2]//option[1]").is_selected(
                ):
            wd.find_element_by_xpath(
                "//div[@id='content']/form/select[2]//option[1]").click()
        if not wd.find_element_by_xpath(
                "//div[@id='content']/form/select[2]//option[1]").is_selected(
                ):
            wd.find_element_by_xpath(
                "//div[@id='content']/form/select[2]//option[1]").click()
        if not wd.find_element_by_xpath(
                "//div[@id='content']/form/select[2]//option[1]").is_selected(
                ):
            wd.find_element_by_xpath(
                "//div[@id='content']/form/select[2]//option[1]").click()
        if not wd.find_element_by_xpath(
                "//div[@id='content']/form/select[2]//option[1]").is_selected(
                ):
            wd.find_element_by_xpath(
                "//div[@id='content']/form/select[2]//option[1]").click()
        if not wd.find_element_by_xpath(
                "//div[@id='content']/form/select[2]//option[2]").is_selected(
                ):
            wd.find_element_by_xpath(
                "//div[@id='content']/form/select[2]//option[2]").click()
        wd.find_element_by_name("byear").click()
        wd.find_element_by_name("byear").clear()
        wd.find_element_by_name("byear").send_keys("2010")
        if not wd.find_element_by_xpath(
                "//div[@id='content']/form/select[3]//option[14]").is_selected(
                ):
            wd.find_element_by_xpath(
                "//div[@id='content']/form/select[3]//option[14]").click()
        if not wd.find_element_by_xpath(
                "//div[@id='content']/form/select[3]//option[14]").is_selected(
                ):
            wd.find_element_by_xpath(
                "//div[@id='content']/form/select[3]//option[14]").click()
        if not wd.find_element_by_xpath(
                "//div[@id='content']/form/select[3]//option[14]").is_selected(
                ):
            wd.find_element_by_xpath(
                "//div[@id='content']/form/select[3]//option[14]").click()
        if not wd.find_element_by_xpath(
                "//div[@id='content']/form/select[4]//option[1]").is_selected(
                ):
            wd.find_element_by_xpath(
                "//div[@id='content']/form/select[4]//option[1]").click()
        if not wd.find_element_by_xpath(
                "//div[@id='content']/form/select[4]//option[2]").is_selected(
                ):
            wd.find_element_by_xpath(
                "//div[@id='content']/form/select[4]//option[2]").click()
        wd.find_element_by_name("ayear").click()
        wd.find_element_by_name("ayear").clear()
        wd.find_element_by_name("ayear").send_keys("2020")
        wd.find_element_by_name("theform").click()
        wd.find_element_by_name("address2").click()
        wd.find_element_by_name("address2").clear()
        wd.find_element_by_name("address2").send_keys("123")
        wd.find_element_by_name("phone2").click()
        wd.find_element_by_name("phone2").clear()
        wd.find_element_by_name("phone2").send_keys("123")
        wd.find_element_by_name("notes").click()
        wd.find_element_by_name("notes").clear()
        wd.find_element_by_name("notes").send_keys("123")
        wd.find_element_by_xpath("//div[@id='content']/form/input[21]").click()
        self.assertTrue(success)

    def tearDown(self):
        self.wd.quit()
Beispiel #42
0
 def setUpClass(cls):
     super().setUpClass()
     cls.selenium = WebDriver()
     cls.selenium.implicitly_wait(10)
Beispiel #43
0
class HW_new_contact(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver(capabilities={"marionette": False})
        self.wd.implicitly_wait(60)
    
    def test_HW_new_contact(self):
        wd = self.wd
        self.open_webpage(wd)
        self.login(wd, username="******", password="******")
        wd.find_element_by_xpath("//form[@id='LoginForm']/input[3]").click()
        self.link_to_group_page(wd)
        self.create_a_new_group(wd, Group(name="group.Chupakabra", header="group.Chupakabra Header",
                                          footer="group.Chupakabra footer"))
        self.group_verification(wd)
        self.new_contac_page(wd)
        self.contact_information(wd, Contact(firstname="Abra", middlename="Kadabra",
                                             lastname="Chupakabra", nickname="Chupakabra", title="My Title",
                                             company="Home", address="557 Mayfair Walk Ave, Las Vegas NV 89173",
                                             home="7023542185", mobile="6504655622", work="7023336669",
                                             fax="1234567890", email="*****@*****.**", email2="*****@*****.**",
                                             email3="test.mail.ru", homepage="yahoo.com",
                                             address2="123 new address test", phone2="123 home address",
                                             notes="my notes bla bla bla"))
        self.submit_cotact_information(wd)
        wd.find_element_by_link_text("Logout").click()

    def submit_cotact_information(self, wd):
        wd.find_element_by_xpath("//div[@id='content']/form/input[21]").click()

    def contact_information(self, wd, contact):
        wd.find_element_by_name("firstname").click()
        wd.find_element_by_name("firstname").clear()
        wd.find_element_by_name("firstname").send_keys(contact.firstname)
        wd.find_element_by_name("middlename").click()
        wd.find_element_by_name("middlename").clear()
        wd.find_element_by_name("middlename").send_keys(contact.middlename)
        wd.find_element_by_name("lastname").click()
        wd.find_element_by_name("lastname").clear()
        wd.find_element_by_name("lastname").send_keys(contact.lastname)
        wd.find_element_by_name("nickname").click()
        wd.find_element_by_name("nickname").clear()
        wd.find_element_by_name("nickname").send_keys(contact.nickname)
        wd.find_element_by_name("title").click()
        wd.find_element_by_name("title").clear()
        wd.find_element_by_name("title").send_keys(contact.title)
        wd.find_element_by_name("company").click()
        wd.find_element_by_name("company").clear()
        wd.find_element_by_name("company").send_keys(contact.company)
        wd.find_element_by_name("address").click()
        wd.find_element_by_name("address").clear()
        wd.find_element_by_name("address").send_keys(contact.address)
        wd.find_element_by_name("home").click()
        wd.find_element_by_name("home").clear()
        wd.find_element_by_name("home").send_keys(contact.home)
        wd.find_element_by_name("mobile").click()
        wd.find_element_by_name("mobile").clear()
        wd.find_element_by_name("mobile").send_keys(contact.mobile)
        wd.find_element_by_name("work").click()
        wd.find_element_by_name("work").clear()
        wd.find_element_by_name("work").send_keys(contact.work)
        wd.find_element_by_name("fax").click()
        wd.find_element_by_name("fax").clear()
        wd.find_element_by_name("fax").send_keys(contact.fax)
        wd.find_element_by_name("email").click()
        wd.find_element_by_name("email").clear()
        wd.find_element_by_name("email").send_keys(contact.email)
        wd.find_element_by_name("email2").click()
        wd.find_element_by_name("email2").clear()
        wd.find_element_by_name("email2").send_keys(contact.email2)
        wd.find_element_by_name("email2").click()
        wd.find_element_by_name("email2").clear()
        wd.find_element_by_name("email2").send_keys(contact.email2)
        wd.find_element_by_name("email3").click()
        wd.find_element_by_name("email3").clear()
        wd.find_element_by_name("email3").send_keys(contact.email3)
        wd.find_element_by_name("homepage").click()
        wd.find_element_by_name("homepage").clear()
        wd.find_element_by_name("homepage").send_keys(contact.homepage)
        if not wd.find_element_by_xpath("//div[@id='content']/form/select[1]//option[17]").is_selected():
            wd.find_element_by_xpath("//div[@id='content']/form/select[1]//option[17]").click()
        if not wd.find_element_by_xpath("//div[@id='content']/form/select[2]//option[12]").is_selected():
            wd.find_element_by_xpath("//div[@id='content']/form/select[2]//option[12]").click()
        wd.find_element_by_name("byear").click()
        wd.find_element_by_name("byear").clear()
        wd.find_element_by_name("byear").send_keys("1986")
        if not wd.find_element_by_xpath("//div[@id='content']/form/select[3]//option[7]").is_selected():
            wd.find_element_by_xpath("//div[@id='content']/form/select[3]//option[7]").click()
        if not wd.find_element_by_xpath("//div[@id='content']/form/select[4]//option[3]").is_selected():
            wd.find_element_by_xpath("//div[@id='content']/form/select[4]//option[3]").click()
        wd.find_element_by_name("ayear").click()
        wd.find_element_by_name("ayear").clear()
        wd.find_element_by_name("ayear").send_keys("2018")
        if not wd.find_element_by_xpath("//div[@id='content']/form/select[5]//option[2]").is_selected():
            wd.find_element_by_xpath("//div[@id='content']/form/select[5]//option[2]").click()
        wd.find_element_by_name("address2").click()
        wd.find_element_by_name("address2").clear()
        wd.find_element_by_name("address2").send_keys(contact.address2)
        wd.find_element_by_name("phone2").click()
        wd.find_element_by_name("phone2").clear()
        wd.find_element_by_name("phone2").send_keys(contact.phone2)
        wd.find_element_by_name("notes").click()
        wd.find_element_by_name("notes").clear()
        wd.find_element_by_name("notes").send_keys(contact.notes)

    def new_contac_page(self, wd):
        wd.find_element_by_link_text("add new").click()

    def group_verification(self, wd):
        wd.find_element_by_link_text("group page").click()

    def create_a_new_group(self, wd, group):
        wd.find_element_by_name("new").click()
        wd.find_element_by_name("group_name").click()
        wd.find_element_by_name("group_name").clear()
        wd.find_element_by_name("group_name").send_keys(group.name)
        wd.find_element_by_name("group_header").click()
        wd.find_element_by_name("group_header").clear()
        wd.find_element_by_name("group_header").send_keys(group.header)
        wd.find_element_by_name("group_footer").click()
        wd.find_element_by_name("group_footer").clear()
        wd.find_element_by_name("group_footer").send_keys(group.footer)
        wd.find_element_by_name("submit").click()

    def link_to_group_page(self, wd):
        wd.find_element_by_link_text("groups").click()

    def login(self, wd, username="******", password="******"):
        wd.find_element_by_name("user").click()
        wd.find_element_by_name("user").clear()
        wd.find_element_by_name("user").send_keys(username)
        wd.find_element_by_name("pass").click()
        wd.find_element_by_name("pass").clear()
        wd.find_element_by_name("pass").send_keys(password)

    def open_webpage(self, wd):
        wd.get("http://localhost/addressbook/addressbook/edit.php")

    def tearDown(self):
        self.wd.quit()
Beispiel #44
0
 def setUp(self):
     self.wd = WebDriver()
     self.wd.implicitly_wait(60)
 def __init__(self, p_live_server_url):
     self.live_server_url = p_live_server_url
     self.driver = WebDriver()
Beispiel #46
0
 def setUp(self):
     self.wd = WebDriver(capabilities={"marionette": False})
     self.wd.implicitly_wait(60)
 def __init__(self):
     self.wd = WebDriver()
     # self.wd.implicitly_wait(5)
     self.session = SessionHelper(self)
     self.group = GroupHelper(self)
     self.contact = ContactHelper(self)
Beispiel #48
0
                    help="execution timeout in secs (default: 1)")
parser.add_argument("--debug",
                    action="store_false",
                    default=True,
                    help="if passed, show the firefox window",
                    dest="debug")

args = parser.parse_args()
if args.t.endswith("/"):
    args.t = args.t[:-1]

U = ''.join(random.choices(string.ascii_uppercase + string.digits, k=15))

opt = Options()
opt.headless = args.debug
driver = WebDriver(options=opt)
driver.maximize_window()
print(info("Logging in"))
driver.get("%s/admin/login.php" % args.t)
u = driver.find_element_by_xpath("//input[@id='lbusername']").send_keys(args.u)
p = driver.find_element_by_xpath("//input[@id='lbpassword']").send_keys(args.p)
driver.find_element_by_xpath(
    "//body/div[@id='wrapper']/div[1]/div[1]/form[1]/fieldset[1]/input[3]"
).click()

try:
    WebDriverWait(driver, args.timeout).until(
        EC.visibility_of_element_located(
            (By.XPATH,
             "//div[contains(text(),'User name or password incorrect')]")))
    print(bad("User name or password incorrect"))
Beispiel #49
0
class AJAXSchedulingModuleUITest(AJAXSchedulingModuleTestBase,
                                 LiveServerTestCase):
    def setUp(self, *args, **kwargs):
        super(AJAXSchedulingModuleUITest, self).setUp(*args, **kwargs)
        self.browser = WebDriver()
        self.update_interval = 4
        self.filter_interval = 5

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

    def loginAdminBrowser(self, uname, pword):
        uname_el_id = "user"
        pword_el_id = "pass"
        submit_el_id = "gologin"

        self.browser.get(self.live_server_url)

        e = WebDriverWait(self.browser, 10).until(
            lambda driver: self.browser.find_element_by_id(uname_el_id))
        e.send_keys(uname)
        e = WebDriverWait(self.browser, 10).until(
            lambda driver: self.browser.find_element_by_id(pword_el_id))
        e.send_keys(pword)
        e = WebDriverWait(self.browser, 60).until(
            lambda driver: self.browser.find_element_by_id(submit_el_id))
        e.click()

    def loadAjax(self):
        self.loginAdminBrowser(self.admins[0].username, "password")
        url = self.live_server_url + self.ajax_url_base + "ajax_scheduling"
        self.browser.get(url)
        #wait for ajax to load before we go on
        time.sleep(30)

    def hasCSSClass(self, el, class_name):
        css_classes = el.get_attribute("class").split()
        return class_name in css_classes

    def isScheduled(self, section_id):
        elements = self.browser.find_elements_by_class_name('CLS_id_' +
                                                            str(section_id))
        for el in elements:
            self.failIf(self.hasCSSClass(el, "class-entry"),
                        "Scheduled class appears in directory")

        self.failUnless(
            True in [self.hasCSSClass(el, "matrix-cell") for el in elements],
            "Scheduled class does not appear in matrix")

    def isInDirectory(self, section_id):
        elements = self.browser.find_elements_by_class_name('CLS_id_' +
                                                            str(section_id))
        self.failUnless(
            True in [self.hasCSSClass(el, "class-entry") for el in elements],
            "Class does not appear in directory.")

    def isNotInDirectory(self, section_id):
        elements = self.browser.find_elements_by_class_name('CLS_id_' +
                                                            str(section_id))
        for el in elements:
            self.failIf(self.hasCSSClass(el, "class-entry"),
                        "Class appears in directory")

    def isNotScheduled(self, section_id):
        elements = self.browser.find_elements_by_class_name('CLS_id_' +
                                                            str(section_id))
        for el in elements:
            self.failIf(self.hasCSSClass(el, "matrix-cell"),
                        "Unscheduled class appears in matrix")

        self.failUnless(
            True in [self.hasCSSClass(el, "class-entry") for el in elements],
            "Unscheduled class does not appear in directory.")

    #mostly exists as sanity on testing framework
    def testAjaxLoads(self):
        self.loadAjax()
        self.failUnless(self.browser.title == "ESP Scheduling Application",
                        "Did not find AJAX: " + self.browser.title)

    def testUpdateScheduledClass(self):
        self.loadAjax()
        self.clearScheduleAvailability()
        (section, rooms, times) = self.scheduleClass()

        #section turns up in the browser
        time.sleep(self.update_interval)
        self.isScheduled(section.id)

    def testUpdateUnscheduledClass(self):
        self.loadAjax()
        self.clearScheduleAvailability()

        #schedule and unschedule a class
        (section, rooms, times) = self.scheduleClass()
        #wait for class to appear
        time.sleep(self.update_interval)
        self.unschedule_class(section.id)
        time.sleep(self.update_interval)

        self.isNotScheduled(section.id)

    def testUpdateScheduleUnscheduleClass(self):
        #if a class is scheduled and unscheduled in the same log, make sure it doesn't show up
        self.loadAjax()
        self.clearScheduleAvailability()

        #schedule and unschedule a class
        (section, rooms, times) = self.scheduleClass()
        self.unschedule_class(section.id)
        time.sleep(self.update_interval)

        self.isNotScheduled(section.id)

    # test basic drag-and-drop scheduling
    # this test does not seem to work correctly
    #
    # def testScheduleClass(self):
    #     self.loadAjax()
    #     self.clearScheduleAvailability()

    #     (section, room, times) = self.getClassToSchedule()
    #     source_el = self.browser.find_element_by_class_name('CLS_id_'+str(section.id))
    #     #any matrix cell will work
    #     target_el = self.browser.find_element_by_class_name('matrix-cell')

    #     ac = ActionChains(self.browser)
    #     ac.drag_and_drop(source_el, target_el).perform()
    #     time.sleep(5)
    #     self.isScheduled(section.id)

    #####################################################################################
    #
    #   FILTERING TESTS
    #
    #####################################################################################

    def filter_directory(self, label, value):
        #   Expand the filtering accordiion
        self.browser.find_element_by_id("filtering_header").click()
        time.sleep(1.0)
        #   Type into the desired filtering element
        f = self.browser.find_element_by_id("filter_" + label)
        f.send_keys(value + "\n")
        time.sleep(self.filter_interval)

    def testTitleFilter(self):
        self.loadAjax()

        section = self.program.sections()[0]

        self.filter_directory("Title", section.title())

        for s in self.program.sections():
            if (s == section):
                self.isInDirectory(s.id)
            else:
                self.isNotInDirectory(s.id)

    #TODO:  none of the classes have teachers with names
    def testTeacherFilter(self):
        self.loadAjax()
        self.clearScheduleAvailability()

        teacher = self.teachers[0]

        self.filter_directory("Teacher", teacher.name())

        for s in self.program.sections():
            if teacher in s.teachers:
                self.isInDirectory(s.id)
            else:
                self.isNotInDirectory(s.id)

    def testFilterUnscheduledClass(self):
        self.loadAjax()
        self.clearScheduleAvailability()

        (section, rooms, times) = self.scheduleClass()
        self.browser.find_element_by_id("filtering_header").click()
        title_filter = self.browser.find_element_by_id("filter_ID")
        title_filter.send_keys(
            "xuoeahtuoeathsnuoeathns\n"
        )  #something I'm pretty sure won't appear in an id
        time.sleep(self.update_interval)

        self.unschedule_class(section.id)
        time.sleep(self.update_interval)

        self.isNotInDirectory(section.id)

    #TODO:  change some class length so we see it not filtering some stuff
    def testLengthFilter(self):
        self.loadAjax()
        self.clearScheduleAvailability()

        self.filter_directory("Min-length", "1")
        self.filter_directory("Max-length", "1")

        for s in self.program.sections():
            #all classes have length 2 in test data
            self.isNotInDirectory(s.id)
class Base:
    @classmethod
    def __init__(self, p_live_server_url):
        self.live_server_url = p_live_server_url
        self.driver = WebDriver()

    @classmethod
    def pause(self, p_seconds):
        try:
            WebDriverWait(self.driver, p_seconds).until(EC.title_is('pause'))
        except:
            pass

    @classmethod
    def grid_cell_doubleclick(self, p_element):
        ActionChains(self.driver).double_click(p_element).perform()

    @classmethod
    def grid_cell_input(self, p_element, p_text):
        self.grid_cell_doubleclick(p_element)
        for k in range(0, len(p_element.text)):
            p_element.send_keys(Keys.BACKSPACE)
        p_element.send_keys(p_text)

    @classmethod
    def action_login(self, p_username, p_password, p_expectsuccess=True):
        self.driver.get('{0}{1}'.format(self.live_server_url, '/login/'))
        WebDriverWait(self.driver, 10).until(
            EC.presence_of_element_located((By.TAG_NAME, 'body')))
        username_input = self.driver.find_element_by_id('txt_user')
        username_input.send_keys(p_username)
        password_input = self.driver.find_element_by_id('txt_pwd')
        password_input.send_keys(p_password)
        self.driver.find_element_by_xpath("//button[. = 'Sign in']").click()
        if p_expectsuccess:
            try:
                WebDriverWait(self.driver, 10).until(
                    EC.presence_of_element_located((By.CLASS_NAME, 'header')))
            except:
                WebDriverWait(self.driver, 10).until(
                    EC.visibility_of_element_located(
                        (By.CLASS_NAME, 'div_alert_text')))
        else:
            try:
                WebDriverWait(self.driver, 10).until(
                    EC.visibility_of_element_located(
                        (By.CLASS_NAME, 'div_alert_text')))
            except:
                WebDriverWait(self.driver, 10).until(
                    EC.presence_of_element_located((By.CLASS_NAME, 'header')))

    @classmethod
    def action_create_user(self, p_username, p_password, p_superuser):
        self.driver.get('{0}{1}'.format(self.live_server_url, '/users/'))
        WebDriverWait(self.driver, 10).until(
            EC.presence_of_element_located((By.TAG_NAME, 'body')))
        assert 'OmniDB' in self.driver.title
        self.driver.find_element_by_xpath("//button[. = 'New User']").click()
        username_cell = self.driver.find_element_by_xpath(
            "//tbody/tr[last()]/td[1]")
        self.grid_cell_input(username_cell, p_username)
        password_cell = self.driver.find_element_by_xpath(
            "//tbody/tr[last()]/td[2]")
        self.grid_cell_input(password_cell, p_password)
        if p_superuser:
            superuser_cell = self.driver.find_element_by_xpath(
                "//tbody/tr[last()]/td[3]")
            self.grid_cell_doubleclick(superuser_cell)
        self.driver.find_element_by_tag_name('body').click()
        self.driver.find_element_by_xpath("//button[. = 'Save Data']").click()
 def setUpClass(cls):
     cls.selenium = WebDriver()
     super(TestAdminPanelWidget, cls).setUpClass()
Beispiel #52
0
 def setUp(self, *args, **kwargs):
     super(AJAXSchedulingModuleUITest, self).setUp(*args, **kwargs)
     self.browser = WebDriver()
     self.update_interval = 4
     self.filter_interval = 5
Beispiel #53
0
class BaseStoreTest(StaticLiveServerTestCase):
    def by_id(self, id):
        return self.selenium.find_element_by_id(id)

    def by_css(self, selector: str, multiple: bool = False):
        if multiple:
            return self.selenium.find_elements_by_css_selector(selector)
        else:
            return self.selenium.find_element_by_css_selector(selector)

    def setUp(self):
        self.selenium = WebDriver()
        self.selenium.implicitly_wait(SELENIUM_WAIT_SEC)
        user = create_user(TEST_USER, TEST_PASSWORD, TEST_EMAIL)
        user.firstname = 'live'
        user.lastname = 'test'
        user.save()

    def tearDown(self):
        try:
            delete_user(TEST_USER)
        except Exception:
            pass
        super().tearDown()
        self.selenium.quit()

    def go_to(self, url_name: str, kwargs: Dict[str, str] = None) -> None:
        app_url = reverse(url_name, kwargs=kwargs)
        self.selenium.get('%s%s' % (self.live_server_url, app_url))

    def go_to_app(self, app_id):
        self.go_to('app-detail', {'id': app_id})

    def go_to_app_register(self):
        self.go_to('app-register')

    def go_to_app_upload(self):
        self.go_to('app-upload')

    def go_to_login(self):
        self.selenium.get('%s%s' % (self.live_server_url, '/login/'))

    def login(self, user: str = TEST_USER, password: str = TEST_PASSWORD):
        self.go_to_login()
        user_input = self.selenium.find_element_by_name("login")
        user_input.send_keys(user)
        pass_input = self.selenium.find_element_by_name("password")
        pass_input.send_keys(password)
        self.selenium.find_element_by_xpath('//button[@type="submit"]').click()

    def logout(self):
        self.findNavigationLink('account_logout').click()

    def wait_for(self, selector: str,
                 then: Callable[[WebElement], None]) -> Any:
        element = WebDriverWait(self.selenium, SELENIUM_WAIT_SEC).until(
            EC.visibility_of_element_located((By.CSS_SELECTOR, selector)))
        return then(element)

    def assertOnPage(self, url_name: str,
                     kwargs: Dict[str, str] = None) -> None:
        parsed = urlparse(self.selenium.current_url)
        url = reverse(url_name, kwargs=kwargs)
        self.assertEqual(url, parsed.path)

    def findNavigationLink(self, url_name: str,
                           kwargs: Dict[str, str] = None):
        route = reverse(url_name, kwargs=kwargs)
        return self.by_css('#navbar a[href="%s"]' % route)
Beispiel #54
0
class BaseLiveServerTestCase(LiveServerTestCase):
    def setUp(self):
        u, c = User.objects.get_or_create(username='******')
        if c:
            u.is_staff = True
            u.set_password('test')
            u.save()

        self.browser = WebDriver()
        self.do_admin_login('test', 'test')

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

    def do_admin_login(self, username, password):
        self.browser.get('%s%s' % (self.live_server_url, '/admin/'))
        username_input = self.browser.find_element_by_name("username")
        username_input.send_keys(username)
        password_input = self.browser.find_element_by_name("password")
        password_input.send_keys(password)
        self.browser.find_element_by_xpath('//input[@value="Log in"]').click()

    def new_window(self, name='other'):
        self.browser.execute_script('window.open("/admin/", "' + name + '")')
        self.browser.switch_to_window(self.browser.window_handles[1])
        while self.warning_element() is False:
            time.sleep(0.1)
        self.browser.switch_to_window(self.browser.window_handles[0])

    def press_space(self):
        a = ActionChains(self.browser)
        a.key_down(Keys.SPACE)
        a.perform()

    def wait_for_pages_loaded(self):
        for win in self.browser.window_handles:
            while self.warning_element() is False:
                time.sleep(0.1)
Beispiel #55
0
class MySeleniumTests(LiveServerTestCase):
    def setUp(self):
        """
        """
        # self.selenium = WebDriver(executable_path='C:/geckodriver.exe')
        self.selenium = WebDriver()
        self.selenium.implicitly_wait(10)
        self.profile = Profile.objects.create_user(
            username='******',
            first_name='wafi',
            last_name='mameri',
            email='*****@*****.**',
            password='******',
            adress1='12 rue',
            adress2='Alger centre',
            ville='Alger centre',
            codezip='16000',
            contry='Algerie',
            phone='2131234',
            discriptions='Bonjour',
            picture='/media/picture/papy.jpeg',
        )
        self.categorie = Categorie.objects.create(name='Vente')
        self.annonce_create = Annonce.objects.create(
            title='Jeux avendre',
            product='Loisirs',
            type_annonce='Jeux video',
            price=20.00,
            categories=self.categorie,
            description='super jeux',
            owner=self.profile,
        )
        self.images_annonce = Image.objects.create(
            annonce_images=self.annonce_create,
            image='/media/picture/papy.jpeg',
        )

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

    def test_login(self):
        """ Test login form
        """
        self.selenium.get('%s%s' % (self.live_server_url, '/accounts/login/'))
        self.selenium.find_element_by_id("id_login").send_keys('wafistos6')
        self.selenium.find_element_by_id("id_password").send_keys('djamel2013')
        self.selenium.find_element_by_id('submitBtn').click()
        time.sleep(7)
        self.assertEquals(self.selenium.title, 'Yatach Home')

    def test_search(self):
        """ Test search form
        """

        self.selenium.get('%s%s' % (self.live_server_url, '/'))
        query = self.selenium.find_element_by_name("q")
        query.send_keys('console')
        self.selenium.find_element_by_id('searchBtn').click()
        self.assertEquals(self.selenium.title, 'Yatach Home')

    def test_add_annonce(self):
        url_add_annonce = "/annonce/add"
        profile = Profile.objects.all().first()
        print(profile.is_active)
        profile.is_active = True
        profile.save()
        print(profile.password)
        self.selenium.get('%s%s' % (self.live_server_url, url_add_annonce))
        self.selenium.find_element_by_id("id_login").send_keys('wafistos6')
        self.selenium.find_element_by_id("id_password").send_keys('djamel2013')
        self.selenium.find_element_by_id('submitBtn').click()
        self.selenium.find_element_by_id("id_title").send_keys('Jeux a vendre')
        self.selenium.find_element_by_id("id_product").send_keys('console')
        self.selenium.find_element_by_id("id_price").send_keys(200)
        self.selenium.find_element_by_id("id_type_annonce").send_keys('Vente')
        self.selenium.find_element_by_id("id_categories").send_keys('LOISIRS')
        self.selenium.find_element_by_id("id_description").send_keys(
            'Jeux occasion')
        self.selenium.find_element_by_class_name('site-btn').click()
Beispiel #56
0
 def setUpClass(cls):
     super().setUpClass()
     cls.browser = WebDriver()
     cls.browser.implicitly_wait(10)
 def setUp(self):
     self.browser = WebDriver()
     self.browser.implicitly_wait(5)
     self.browser.get('http://google.com')
Beispiel #58
0
 def setUpClass(cls):
     if os.environ.get('WITH_SELENIUM', False):
         cls.selenium = WebDriver()
     super(SeleniumTestCase, cls).setUpClass()
Beispiel #59
0
# -*- coding: utf-8 -*-
from selenium.webdriver.firefox.webdriver import WebDriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import time

success = True
wd = WebDriver()
wd.implicitly_wait(60)

def is_alert_present(wd):
    try:
        wd.switch_to_alert().text
        return True
    except:
        return False

try:
    wd.get("http://blazedemo.com/")
    wd.find_element_by_css_selector("input.btn.btn-primary").click()
    wd.find_element_by_css_selector("input.btn.btn-small").click()
    wd.find_element_by_id("inputName").click()
    wd.find_element_by_id("inputName").clear()
    wd.find_element_by_id("inputName").send_keys("test")
    wd.find_element_by_id("address").click()
    wd.find_element_by_id("address").send_keys("\\9")
    wd.find_element_by_id("city").click()
    wd.find_element_by_id("city").send_keys("\\9")
    wd.find_element_by_css_selector("input.btn.btn-primary").click()
finally:
    wd.quit()
Beispiel #60
0
 def setUp(self):
     self.driver = WebDriver()