fix tests

This commit is contained in:
Artur Barseghyan 2019-05-22 12:08:45 +02:00
parent 5517d0f425
commit 9d4dbfa40f
4 changed files with 54 additions and 21 deletions

View file

@ -38,10 +38,10 @@ matrix:
- env: TOX_ENV=py37-django21
python: 3.7
- env: TOX_ENV=py36-django22
python: 3.6
- env: TOX_ENV=py37-django22
python: 3.7
# - env: TOX_ENV=py36-django22
# python: 3.6
# - env: TOX_ENV=py37-django22
# python: 3.7
install:
- wget http://chromedriver.storage.googleapis.com/2.42/chromedriver_linux64.zip

View file

@ -2,6 +2,7 @@ import gc
import logging
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.support.wait import WebDriverWait
@ -207,3 +208,13 @@ class BaseFobiBrowserBuldDynamicFormsTest(LiveServerTestCase):
self.driver.execute_script(
"window.scrollBy({0}, {1});".format(x, y)
)
def _scroll_page_top(self):
"""Scroll to the page top."""
html = self.driver.find_element_by_tag_name('html')
html.send_keys(Keys.HOME)
def _scroll_page_bottom(self):
"""Scroll to the page bottom."""
html = self.driver.find_element_by_tag_name('html')
html.send_keys(Keys.END)

View file

@ -277,29 +277,33 @@ TEST_FORM_FIELD_DATA = {
# 'test_unicode_text': u'Անուն',
}
TEST_FORM_HANDLER_PLUGIN_DATA = {
force_text(DBStoreHandlerPlugin.name): None,
force_text(MailHandlerPlugin.name): {
'from_name': "From me",
'from_email': "from@example.com",
'to_name': "To you",
'to_email': "to@example.com",
'subject': "Test email subject",
'body': "Test email body",
},
force_text(MailSenderHandlerPlugin.name): {
# Order of the elements matters a lot, since `Mail` and `Mail the sender`
# both share the `Mail` word. If order isn't taken into consideration,
# it may happen that the wrong plugin is detected (occasional on Python2).
# Therefore, an ordered dict. Note that `MailSenderHandlerPlugin` shall
# be placed before the `MailHandlerPlugin`.
TEST_FORM_HANDLER_PLUGIN_DATA = OrderedDict([
(force_text(DBStoreHandlerPlugin.name), None),
(force_text(MailSenderHandlerPlugin.name), {
'from_name': "From me",
'from_email': "from@example.com",
'to_name': "To you",
'form_field_name_to_email': "test_email_input",
'subject': "Test email subject",
'body': "Test email body",
},
force_text(HTTPRepostHandlerPlugin.name): {
}),
(force_text(MailHandlerPlugin.name), {
'from_name': "From me",
'from_email': "from@example.com",
'to_name': "To you",
'to_email': "to@example.com",
'subject': "Test email subject",
'body': "Test email body",
}),
(force_text(HTTPRepostHandlerPlugin.name), {
'endpoint_url': 'http://dev.example.com'
}
}
}),
])
TEST_MAILCHIMP_IMPORTER_FORM_DATA = [
{

View file

@ -2,6 +2,7 @@ import logging
import unittest
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.action_chains import ActionChains
from fobi.models import FormEntry
@ -526,8 +527,25 @@ class FobiBrowserBuldDynamicFormsTest(BaseFobiBrowserBuldDynamicFormsTest):
self._sleep(2)
self._scroll_page_bottom()
# Wait until button is there
WebDriverWait(self.driver, timeout=TIMEOUT).until(
lambda driver: driver.find_element_by_xpath(
'//button[@type="submit"]'
)
)
# Click add widget button
self.driver.find_element_by_xpath('//button[@type="submit"]').click()
submit_button = self.driver.find_element_by_xpath('//button[@type="submit"]')
self._scroll_page_bottom()
submit_button.click()
try:
submit_button.click()
except Exception as err:
import pytest; pytest.set_trace()
# Wait until the submit success page opens a clear success message.
WebDriverWait(self.driver, timeout=TIMEOUT).until(