Exemplo n.º 1
0
def fill_in_improv_and_feature_environment_information(
        browser: webdriver.WebDriver, env_template_path: str) -> None:
    """
    :param browser: instance of a selenium.webdriver() object
    :param env_template_path: Path of the file that contains the environment
    information text
    :return: No return value
    """

    try:
        browser.find_element(
            By.LINK_TEXT,
            elements_jira.tab_improvement_others_link_text).click()

    except NoSuchElementException and StaleElementReferenceException:
        logging.error("'Others' tab not found")

    browser.find_element_by_link_text(
        elements_jira.btn_environment_fld_text_link_text).click()

    with open(env_template_path, 'r') as env_template:
        fill_in_element(browser,
                        By.ID,
                        elements_jira.fld_environment_id,
                        env_template.read(),
                        confirm=True)
Exemplo n.º 2
0
class BasicViewTests(unittest.TestCase):
    """
    Just visit all the views and make sure they look okay
    """

    def setUp(self):

        self.selenium = WebDriver()
        self.live_server_url = LIVE_SERVER_URL

        # login boilerplate blah
        self.selenium.get(self.live_server_url + '/login')
        username_input = self.selenium.find_element_by_name("username_or_email")
        username_input.send_keys(ADMIN_USERNAME)
        password_input = self.selenium.find_element_by_name("password")
        password_input.send_keys(ADMIN_PASSWORD)
        self.selenium.find_element_by_xpath('//button[@type="submit"]').click()

    def test_home(self):

        self.selenium.get(self.live_server_url + '/')

        # two project links are there
        self.selenium.find_element_by_link_text('1000 Genomes')

    def test_project_home(self):

        self.selenium.get(self.live_server_url + '/project/1kg')

    def test_family_home(self):

        self.selenium.get(self.live_server_url + '/project/1kg/family/HG1')

    def tearDown(self):
        self.selenium.quit()
Exemplo n.º 3
0
def syn_test_script():

    try:
        success = True
        driver = WebDriver()
        driver.implicitly_wait(30)


        log_output("Starting @ http://www.kay.com/en/kaystore")
        driver.get("http://www.kay.com/en/kaystore")

        log_output("Navigating to Engagement Rings")
        ActionChains(driver).move_to_element(driver.find_element_by_xpath("//div[3]/div[2]/div/div/div[3]/nav/div/ul/li[4]/a[2]")).perform()
        driver.find_element_by_xpath("//div[3]/div[2]/div/div/div[3]/nav/div/ul/li[4]/ul/li[2]/div/div/div[2]/ul/li[2]/ul/li/ul/li[1]/a").click()

        time.sleep(2)
        if not ("Engagement" in driver.find_element_by_tag_name("html").text):
            success = False
            print("Did not find word engagement on page in reasonable time")

        log_output("Changing price range to 3rd facet")
        if not driver.find_element_by_id("facet_checkbox7").is_selected():
            driver.find_element_by_id("facet_checkbox7").click()
        time.sleep(3)

        log_output("Viewing more rings")
        driver.find_element_by_id("view-more").click()

        log_output("Select a nice ring")
        driver.find_element_by_xpath("//div[3]/div[2]/div/div/div[4]/div[7]/div[2]/div[2]/div[7]/div[37]/div/a/img").click()

        #log_output("starting timer")
        #time.sleep(5)
        log_output("Add Ring to bag")
        # There is a bit of funkiness with this Product page and the overlay when you add an item to Cart
        # Sometimes the addToCartBtn is not immediately available and can time out or error out
        # The 5 second sleep timer above is disabled, but if we see issues this may need re-anabled
        # or use WebDriverWait
        ActionChains(driver).move_to_element(driver.find_element_by_xpath("//a[@id='addToCartBtn']")).perform()
        driver.find_element_by_xpath("//a[@id='addToCartBtn']")
        driver.find_element_by_xpath("//a[@id='addToCartBtn']").click()

        log_output("Adding coverage")
        driver.find_element_by_link_text("ADD TO BAG").click()

        log_output("Checking out with a beautiful ring!")
        driver.find_element_by_link_text("CHECKOUT").click()
        if not ("Shopping Bag (1 Item)" in driver.find_element_by_tag_name("html").text):
            success = False
            print("verifyTextPresent failed")

    finally:
        driver.quit()
        if not success:
            raise Exception("Test failed.")
Exemplo n.º 4
0
class Precondition(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)

    def tearDown(self):
        # We should delete all created test form
        self.deete_group()

        self.wd.find_element_by_link_text("Logout").click()
        self.wd.quit()
Exemplo n.º 5
0
class LoginTest(LiveServerTestCase):
    def setUp(self):
        self.browser = WebDriver()
        self.browser.implicitly_wait(5)

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

    def test_title(self):
        open_page(self.browser, '/login/', self.live_server_url)
        self.assertIn('Login Supernova', self.browser.title)

    def test_login_correct(self):
        create_user('john', '*****@*****.**', 'johnpassword')
        steps_to_login(self.browser, self.live_server_url, 'john',
                       'johnpassword')
        self.assertIn('Index', self.browser.title)

    def test_login_incorrect(self):
        create_user('john', '*****@*****.**', 'johnpassword')
        steps_to_login(self.browser, self.live_server_url, 'john1',
                       'johnpassword1')
        login_incorrect = self.browser.find_element_by_tag_name('body')
        self.assertIn('Invalid login details supplied.', login_incorrect.text)

    def test_login_and_logout(self):
        create_user('john', '*****@*****.**', 'johnpassword')
        steps_to_login(self.browser, self.live_server_url, 'john',
                       'johnpassword')
        login_successful = self.browser.find_element_by_tag_name('strong')
        self.assertIn('Welcome to Supernova', login_successful.text)
        link_logout = self.browser.find_element_by_link_text('Logout')
        link_logout.click()
        logout_sucessful = self.browser.find_element_by_tag_name('h1')
        self.assertIn('Login to Supernova', logout_sucessful.text)

    def test_login_logout_and_login(self):
        create_user('john', '*****@*****.**', 'johnpassword')
        steps_to_login(self.browser, self.live_server_url, 'john',
                       'johnpassword')
        login_successful = self.browser.find_element_by_tag_name('strong')
        self.assertIn('Welcome to Supernova', login_successful.text)
        link_logout = self.browser.find_element_by_link_text('Logout')
        link_logout.click()
        logout_sucessful = self.browser.find_element_by_tag_name('h1')
        self.assertIn('Login to Supernova', logout_sucessful.text)
        steps_to_login(self.browser, self.live_server_url, 'john',
                       'johnpassword')
        login_successful = self.browser.find_element_by_tag_name('strong')
        self.assertIn('Welcome to Supernova', login_successful.text)
Exemplo n.º 6
0
class TestContact(ContractBase):
    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)

    def test_of_add_new_valid_contact(self):
        """
        Validation of add correct new contact with full data
        """

        wd = self.wd
        self.open_home_page(wd)
        self.login(wd, UserLogin.name, UserLogin.password)

        self.add_contract(wd)
        self.add_full_name(wd, first_name=Profinity.correct_data, last_name=Profinity.correct_data,
                           middle_name=Profinity.correct_data, nickname=Profinity.correct_data)

        self.add_title(wd, title=Profinity.correct_data)
        self.add_company(wd, company_name=Profinity.correct_data)
        self.add_address(wd, address_name=Profinity.correct_data)

        self.add_phone_number(wd, work=Profinity.correct_phone_number, fax=Profinity.correct_phone_number,
                              home=Profinity.correct_phone_number, mobile=Profinity.correct_phone_number)

        self.add_email(wd, email1=Profinity.correct_email, email2=Profinity.correct_email,
                       email3=Profinity.correct_email)

        self.add_homepage(wd, homepage=Profinity.correct_data)
        self.add_year(wd)

        # secondary data
        self.add_secondary_adress(wd, address=Profinity.correct_data)
        self.add_secondary_home(wd, phone=Profinity.correct_data)
        self.add_secondary_notes(wd, notes=Profinity.correct_data)
        wd.find_element_by_xpath("//div[@id='content']/form/input[21]").click()


    def tearDown(self):
        # Here should use some method to delete test data, i will try do it ASAP
        # TODO:
        '''self.wd.find_element_by_link_text("home").click()
        if not self.wd.find_element_by_id("MassCB").is_selected():
            self.wd.find_element_by_id("MassCB").click()
        self.wd.find_element_by_xpath("//div[@id='content']/form[2]/div[2]/input").click()'''

        self.wd.find_element_by_link_text("Logout").click()
Exemplo n.º 7
0
def send_offer(cipher, job_reference, client, buyer_reference,
        worker_reference):
    driver = WebDriver()
    driver.implicitly_wait(time_to_wait=10)

    # Login
    selenium_login(webdriver=driver)

    # Worker's page
    driver.get('https:/www.odesk.com/users/%s' % cipher)
    driver.find_element_by_link_text("Contact").click()

    # Make an offer link
    driver.find_element_by_id("jsMakeOfferLink").click()
    el = driver.find_element_by_css_selector("#jsTeamSelector > select")
    el.find_element_by_css_selector("option[value=\"%s\"]" % buyer_reference).\
        click()
    driver.find_element_by_id("jsMakeOfferProceed").click()

    # Sign in to make an offer
    driver.find_element_by_id("password").clear()
    driver.find_element_by_id("password").send_keys(settings.ODESK_TEST_ACC_PASS)
    try:
        driver.find_element_by_id("answer").clear()
        driver.find_element_by_id("answer").send_keys(settings.ODESK_TEST_ACC_ANSWER)
    except selenium.exceptions.NoSuchElementException:
        pass
    driver.find_element_by_id("submitButton").click()

    # Make an offer form
    driver.find_element_by_id("useExistingJob-yes").click()
    el = driver.find_element_by_id("jobPosting")
    el.find_element_by_css_selector("option[value=\"%s\"]" % job_reference).\
        click()
    driver.find_element_by_id("employerRate").clear()
    driver.find_element_by_id("employerRate").send_keys("0.01")
    driver.find_element_by_id("setLimit-yes").click()
    driver.find_element_by_id("limit").clear()
    driver.find_element_by_id("limit").send_keys("0")
    driver.find_element_by_id("submitButton").click()

    # Agreement
    driver.find_element_by_id("agreement").click()
    driver.find_element_by_id("submitButton").click()

    driver.close()
Exemplo n.º 8
0
class LoginTest(LiveServerTestCase):
    
    def setUp(self):
        self.browser = WebDriver()
        self.browser.implicitly_wait(5)

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

    def test_title(self):
        open_page(self.browser, '/login/', self.live_server_url)
        self.assertIn('Login Supernova', self.browser.title)
        
    def test_login_correct(self):
        create_user('john','*****@*****.**','johnpassword')
        steps_to_login(self.browser,self.live_server_url,'john','johnpassword')
        self.assertIn('Index', self.browser.title)
    
    def test_login_incorrect(self):
        create_user('john','*****@*****.**','johnpassword')
        steps_to_login(self.browser,self.live_server_url,'john1','johnpassword1')
        login_incorrect = self.browser.find_element_by_tag_name('body')
        self.assertIn('Invalid login details supplied.', login_incorrect.text)
        
    def test_login_and_logout(self): 
        create_user('john','*****@*****.**','johnpassword')
        steps_to_login(self.browser,self.live_server_url,'john','johnpassword')
        login_successful = self.browser.find_element_by_tag_name('strong')
        self.assertIn('Welcome to Supernova', login_successful.text)
        link_logout = self.browser.find_element_by_link_text('Logout')
        link_logout.click()
        logout_sucessful = self.browser.find_element_by_tag_name('h1')
        self.assertIn('Login to Supernova',logout_sucessful.text)
    
    def test_login_logout_and_login(self): 
        create_user('john','*****@*****.**','johnpassword')
        steps_to_login(self.browser,self.live_server_url,'john','johnpassword')
        login_successful = self.browser.find_element_by_tag_name('strong')
        self.assertIn('Welcome to Supernova', login_successful.text)
        link_logout = self.browser.find_element_by_link_text('Logout')
        link_logout.click()
        logout_sucessful = self.browser.find_element_by_tag_name('h1')
        self.assertIn('Login to Supernova',logout_sucessful.text)
        steps_to_login(self.browser,self.live_server_url,'john','johnpassword')
        login_successful = self.browser.find_element_by_tag_name('strong')
        self.assertIn('Welcome to Supernova', login_successful.text)
Exemplo n.º 9
0
class TestGroup(unittest.TestCase):

    def setUp(self):
        self.wd = WebDriver()
        self.wd.implicitly_wait(60)
    
    def test_create_group(self):
        """Validation of correct create test group"""
        success = True
        wd = self.wd
        wd.get("http://localhost/addressbook/group.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_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_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")
        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("test")
        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("test")
        wd.find_element_by_name("submit").click()
        wd.find_element_by_css_selector("div.msgbox").click()
        wd.find_element_by_link_text("group page").click()
        self.assertTrue(success)
    
    def tearDown(self):
        success = True
        # We should delete all created test form
        self.wd.find_element_by_link_text("groups").click()
        self.wd.find_element_by_css_selector("span.group").click()
        if not self.wd.find_element_by_name("selected[]").is_selected():
            self.wd.find_element_by_name("selected[]").click()
        self.wd.find_element_by_xpath("//div[@id='content']/form/input[5]").click()
        self.wd.find_element_by_link_text("Logout").click()
        self.assertTrue(success)
        self.wd.quit()
Exemplo n.º 10
0
def fill_in_description(browser: webdriver.WebDriver, desc_template_path):
    """
    The fill_in_desc_template(browser, desc_template_path) fills the content of
    the description text file into the designated field
    :param browser: instance of a selenium.webdriver() object
    :param desc_template_path: Path to the description input text file
    :return: No return value
    """
    try:
        browser.find_element(By.LINK_TEXT,
                             elements_jira.tab_info_link_text).click()
    except NoSuchElementException and StaleElementReferenceException:
        logging.error("'Info' tab not found")

    browser.find_element_by_link_text(
        elements_jira.btn_description_fld_text_link_text).click()
    fill_in_element(browser, By.ID, elements_jira.fld_description_id,
                    open(desc_template_path).read())
Exemplo n.º 11
0
Arquivo: tests.py Projeto: astucse/SAS
class LoginRegUrlSettingsTest(LiveServerTestCase):
    def setUp(self):
        self.browser = WebDriver()
        self.browser.implicitly_wait(3)
        self.n1 = Node.objects.create(title='TestNodeOne',
                                      description='The first test node')
        self.u1 = User.objects.create_user(username='******',
                                           email='*****@*****.**',
                                           password='******')
        self.t1 = Topic.objects.create(
            title='Test Topic 1',
            user=self.u1,
            content_raw='This is test topic __1__',
            node=self.n1,
        )

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

    @override_settings(NIJI_LOGIN_URL_NAME="reg")
    def test_login_url_name(self):
        self.browser.get(self.live_server_url + reverse("index"))
        login_btn = self.browser.find_element_by_link_text("Log in")
        self.assertEqual(login_btn.get_attribute("href"),
                         self.live_server_url + reverse("reg"))

        self.browser.get(self.live_server_url +
                         reverse("topic", kwargs={"pk": self.t1.pk}))
        login_link = self.browser.find_element_by_link_text("Login")
        self.assertEqual(login_link.get_attribute("href"),
                         self.live_server_url + reverse("reg"))

    @override_settings(NIJI_REG_URL_NAME="login")
    def test_reg_url_name(self):
        self.browser.get(self.live_server_url + reverse("index"))
        reg_btn = self.browser.find_element_by_link_text("Reg")
        self.assertEqual(reg_btn.get_attribute("href"),
                         self.live_server_url + reverse("login"))

        self.browser.get(self.live_server_url +
                         reverse("topic", kwargs={"pk": self.t1.pk}))
        reg_link = self.browser.find_element_by_link_text("Create a New User")
        self.assertEqual(reg_link.get_attribute("href"),
                         self.live_server_url + reverse("login"))
Exemplo n.º 12
0
def fill_in_environment_information(browser: webdriver.WebDriver,
                                    issue_type: str,
                                    template_path: str) -> None:
    """
    :param browser: instance of a selenium.webdriver() object
    :param template_path: Path of the file that contains the environment
    information text
    :param issue_type: Issue name
    :return: No return value
    """
    if issue_type == "bug":
        try:
            browser.find_element(
                By.LINK_TEXT, elements_jira.tab_bug_details_link_text).click()

        except NoSuchElementException and StaleElementReferenceException:
            logging.error("'Bug Details' tab not found")

        browser.find_element_by_link_text(
            elements_jira.btn_environment_fld_text_link_text).click()

    elif issue_type == "improvement" or "feature":
        try:
            browser.find_element(
                By.LINK_TEXT,
                elements_jira.tab_improvement_others_link_text).click()

        except NoSuchElementException and StaleElementReferenceException:
            logging.error("'Others' tab not found")

        browser.find_element_by_link_text(
            elements_jira.btn_environment_fld_text_link_text).click()

    else:
        logging.error("Environment info cannot be inserted for type " +
                      issue_type)
        pass

    with open(template_path, 'r') as env_template:
        fill_in_element(browser,
                        By.ID,
                        elements_jira.fld_environment_id,
                        env_template.read(),
                        confirm=True)
Exemplo n.º 13
0
class HomePageSeleleniumTests(StaticLiveServerTestCase):
    """Selenium tests for the home page"""

    def setUp(self):
        """Opens the home page"""
        self.selenium = WebDriver()
        self.selenium.get('{0}{1}'.format(self.live_server_url, '/'))

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

    def test_elements(self):
        """Tests to ensure the proper elements are present"""
        self.selenium.find_elements_by_link_text('iU')
        self.selenium.find_elements_by_link_text('Welcome')
        about_us = self.selenium\
            .find_elements_by_xpath('//*[@href="#about-us"]')
        assert_true(len(about_us), 2)
        self.selenium.find_element_by_link_text('Features').click()
Exemplo n.º 14
0
Arquivo: tests.py Projeto: ericls/niji
class LoginRegUrlSettingsTest(LiveServerTestCase):

    def setUp(self):
        self.browser = WebDriver()
        self.browser.implicitly_wait(3)
        self.n1 = Node.objects.create(
            title='TestNodeOne',
            description='The first test node'
        )
        self.u1 = User.objects.create_user(
            username='******', email='*****@*****.**', password='******'
        )
        self.t1 = Topic.objects.create(
            title='Test Topic 1',
            user=self.u1,
            content_raw='This is test topic __1__',
            node=self.n1,
        )

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

    @override_settings(NIJI_LOGIN_URL_NAME="niji:reg")
    def test_login_url_name(self):
        self.browser.get(self.live_server_url+reverse("niji:index"))
        login_btn = self.browser.find_element_by_link_text("Log in")
        self.assertEqual(login_btn.get_attribute("href"), self.live_server_url+reverse("niji:reg"))

        self.browser.get(self.live_server_url+reverse("niji:topic", kwargs={"pk": self.t1.pk}))
        login_link = self.browser.find_element_by_link_text("Login")
        self.assertEqual(login_link.get_attribute("href"), self.live_server_url+reverse("niji:reg"))

    @override_settings(NIJI_REG_URL_NAME="niji:login")
    def test_reg_url_name(self):
        self.browser.get(self.live_server_url+reverse("niji:index"))
        reg_btn = self.browser.find_element_by_link_text("Reg")
        self.assertEqual(reg_btn.get_attribute("href"), self.live_server_url+reverse("niji:login"))

        self.browser.get(self.live_server_url+reverse("niji:topic", kwargs={"pk": self.t1.pk}))
        reg_link = self.browser.find_element_by_link_text("Create a New User")
        self.assertEqual(reg_link.get_attribute("href"), self.live_server_url+reverse("niji:login"))
Exemplo n.º 15
0
    try:
        wd.switch_to_alert().text
        return True
    except:
        return False

try:
    wd.get("http://localhost/addressbook/index.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_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("adfadf")
    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("adfadfadf")
    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("adfadfdf")
    wd.find_element_by_name("submit").click()
    wd.find_element_by_link_text("groups").click()
    wd.find_element_by_link_text("Logout").click()
    wd.find_element_by_name("user").click()
    wd.find_element_by_name("user").send_keys("\\224")
Exemplo n.º 16
0
Arquivo: tests.py Projeto: gladuo/niji
class VisitorTest(LiveServerTestCase):
    """
    Test as a visitor (unregistered user)
    """

    def setUp(self):
        self.browser = WebDriver()
        self.browser.implicitly_wait(3)
        self.n1 = Node.objects.create(
            title='TestNodeOne',
            description='The first test node'
        )
        self.u1 = User.objects.create_user(
            username='******', email='*****@*****.**', password='******'
        )
        self.u2 = User.objects.create_user(
            username='******', email='*****@*****.**', password='******'
        )

        # Create 99 topics
        for i in range(1, 100):
            setattr(
                self,
                't%s' % i,
                Topic.objects.create(
                    title='Test Topic %s' % i,
                    user=self.u1,
                    content_raw='This is test topic __%s__' % i,
                    node=self.n1
                )
            )

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

    def test_index(self):
        self.browser.get(self.live_server_url+reverse('niji:index'))
        self.assertIn('niji', self.browser.page_source.lower())

    def test_topic_page_content(self):
        self.browser.get(self.live_server_url+reverse('niji:topic', kwargs={'pk': self.t88.pk}))
        self.assertIn('This is test topic <strong>88</strong>', self.browser.page_source)

    def test_node_page(self):
        self.browser.get(self.live_server_url+reverse('niji:node', kwargs={'pk': self.n1.pk}))
        topics = self.browser.find_elements_by_css_selector('ul.topic-list > li')
        self.assertEqual(len(topics), 30)

    def test_user_login(self):
        self.browser.get(self.live_server_url+reverse('niji:index'))
        self.assertNotIn("Log out", self.browser.page_source)
        login(self.browser, "test1", "111")
        self.assertEqual(self.browser.current_url, self.live_server_url+reverse("niji:index"))
        self.assertIn("Log out", self.browser.page_source)

    def test_usr_reg(self):
        self.browser.get(self.live_server_url+reverse('niji:index'))
        self.browser.find_element_by_link_text("Reg").click()
        self.assertEqual(self.browser.current_url, self.live_server_url+reverse("niji:reg"))
        username = self.browser.find_element_by_name('username')
        email = self.browser.find_element_by_name('email')
        password1 = self.browser.find_element_by_name('password1')
        password2 = self.browser.find_element_by_name('password2')
        username.send_keys("test3")
        password1.send_keys("333")
        password2.send_keys("333")
        email.send_keys("*****@*****.**")
        password1.send_keys(Keys.RETURN)
        self.assertEqual(self.browser.current_url, self.live_server_url+reverse("niji:index"))
        self.assertIn("Log out", self.browser.page_source)
        self.assertIn("test3", self.browser.page_source)

    def test_user_topic(self):
        self.browser.get(self.live_server_url+reverse("niji:user_topics", kwargs={"pk": self.u1.id}))
        self.assertIn("UID:", self.browser.page_source)

    def test_user_info(self):
        self.browser.get(self.live_server_url+reverse("niji:user_info", kwargs={"pk": self.u1.id}))
        self.assertIn("Topics created by %s" % self.u1.username, self.browser.page_source)

    def test_search(self):
        self.browser.get(self.live_server_url+reverse("niji:search", kwargs={"keyword": "test"}))
        self.assertIn("Search: test", self.browser.page_source)

    def test_pagination(self):
        self.browser.get(self.live_server_url+reverse("niji:index", kwargs={"page": 2}))
        self.assertIn("«", self.browser.page_source)
        prev = self.browser.find_element_by_link_text("«")
        prev.click()
        self.assertNotIn("«", self.browser.page_source)
        self.assertIn("»", self.browser.page_source)
        nxt = self.browser.find_element_by_link_text("»")
        nxt.click()
        self.assertEqual(self.browser.current_url, self.live_server_url+reverse("niji:index", kwargs={"page": 2}))
Exemplo n.º 17
0

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


try:
    wd.get("http://localhost/addressbook/group.php")
    wd.find_element_by_name("pass").click()
    wd.find_element_by_name("pass").send_keys("\\undefined")
    wd.find_element_by_xpath("//form[@id='LoginForm']/input[3]").click()
    wd.find_element_by_link_text("home").click()
    if not wd.find_element_by_xpath(
            "//form[@id='right']/select//option[4]").is_selected():
        wd.find_element_by_xpath(
            "//form[@id='right']/select//option[4]").click()
    if not wd.find_element_by_xpath("//input[@id='488']").is_selected():
        wd.find_element_by_xpath("//input[@id='488']").click()
    wd.find_element_by_xpath(
        "//div[@id='content']/form[2]/div[3]/input").click()
    wd.find_element_by_xpath(
        "//div[@class='msgbox']//a[.='group page \"nameRRK\"']").click()
finally:
    wd.quit()
    if not success:
        raise Exception("Test failed.")
Exemplo n.º 18
0
     break
 for course in courses:
     try:
         wait = randint(30, 300)
         wd.implicitly_wait(wait)
         wd.get(
             "https://acorn.utoronto.ca/sws/welcome.do?welcome.dispatch#/")
         if wd.find_elements_by_id("inputID"):
             wd.find_element_by_id("inputID").click()
             wd.find_element_by_id("inputID").clear()
             wd.find_element_by_id("inputID").send_keys(utorid)
             wd.find_element_by_id("inputPassword").click()
             wd.find_element_by_id("inputPassword").clear()
             wd.find_element_by_id("inputPassword").send_keys(password)
             wd.find_element_by_name("login").click()
         wd.find_element_by_link_text("Manage Courses").click()
         wd.find_element_by_link_text(program_year).click()
         wd.find_element_by_id("searchBox").click()
         wd.find_element_by_id("searchBox").clear()
         wd.find_element_by_id("searchBox").send_keys(course)
         wd.find_element_by_id("searchBox").click()
         WebDriverWait(wd, 10).until(
             EC.presence_of_element_located(
                 (By.ID, "course_search_results_list")))
         wd.find_elements_by_xpath(
             "//ul[@id='course_search_results_list']//li//a")[term].click()
         if wd.find_elements_by_link_text("Enrol"):
             wd.find_element_by_link_text("Enrol").click()
             courses.remove(course)
             print("%s was successfully enrolled. Congrats!\n" % course)
             break
Exemplo n.º 19
0
class ProfessorTest(LiveServerTestCase):
    def setUp(self):
        self.browser = WebDriver()
        self.browser.implicitly_wait(1)
        create_user_and_login(self.browser, self.live_server_url, 'john',
                              'johnpassword', '*****@*****.**')
        self.name_professor = 'teste'

    def tearDown(self):
        [professor.delete() for professor in Professor.find()]
        self.browser.quit()

    def create_professor(self, professor_name):
        open_page(self.browser, '/interface/professor', self.live_server_url)
        button_create_professor = self.browser.find_element_by_name('criar')
        button_create_professor.click()
        self.assertIn('Interface - Professor Create', self.browser.title)
        form_name = self.browser.find_element_by_id('id_name')
        form_name.send_keys(professor_name)
        form_memberId = self.browser.find_element_by_id('id_memberId')
        form_memberId.send_keys('00000')
        form_office = self.browser.find_element_by_id('id_office')
        form_office.send_keys('0')
        form_email = self.browser.find_element_by_id('id_email')
        form_email.send_keys('0')
        form_phoneNumber = self.browser.find_element_by_id('id_phoneNumber')
        form_phoneNumber.send_keys('0')
        form_cellphoneNumber = self.browser.find_element_by_id(
            'id_cellphoneNumber')
        form_cellphoneNumber.send_keys('0')
        form_idDepartment = self.browser.find_element_by_id('id_idDepartment')
        form_idDepartment.send_keys('')
        button_submit = self.browser.find_element_by_name('Cadastrar')
        button_submit.click()

    def test_login_to_interface_page(self):
        self.assertIn('Index', self.browser.title)
        link_interface = self.browser.find_element_by_link_text('Interface')
        link_interface.click()
        self.assertIn('Interface', self.browser.title)

    def test_login_to_professor_page(self):
        open_page(self.browser, '/interface/', self.live_server_url)
        professor_interface = self.browser.find_element_by_link_text(
            'Professor')
        professor_interface.click()
        self.assertIn('Interface - Professor', self.browser.title)

    def test_create_professor(self):
        self.create_professor(self.name_professor)
        open_page(self.browser, '/interface/professor', self.live_server_url)
        professor_name_link = self.browser.find_element_by_link_text(
            self.name_professor)
        self.assertIsNotNone(professor_name_link)

    def test_edit_professor(self):
        professor = Professor(self.name_professor)
        professor.store()
        open_page(self.browser, '/interface/professor', self.live_server_url)
        professor_name_link = self.browser.find_element_by_link_text(
            self.name_professor)
        professor_name_link.click()
        self.assertIn('Interface - Professor Detail', self.browser.title)
        button_edit = self.browser.find_element_by_name('editar')
        button_edit.click()
        self.assertIn('Interface - Professor Edit', self.browser.title)
        form_name = self.browser.find_element_by_id('id_name')
        form_name.send_keys('Edit')
        form_memberId = self.browser.find_element_by_id('id_memberId')
        form_memberId.send_keys('')
        form_office = self.browser.find_element_by_id('id_office')
        form_office.send_keys('')
        form_email = self.browser.find_element_by_id('id_email')
        form_email.send_keys('')
        form_phoneNumber = self.browser.find_element_by_id('id_phoneNumber')
        form_phoneNumber.send_keys('0')
        form_cellphoneNumber = self.browser.find_element_by_id(
            'id_cellphoneNumber')
        form_cellphoneNumber.send_keys('0')
        form_idDepartment = self.browser.find_element_by_id('id_idDepartment')
        form_idDepartment.send_keys('')
        button_apply = self.browser.find_element_by_name('Aplicar')
        button_apply.click()
        open_page(self.browser, '/interface/professor', self.live_server_url)
        professor_name_link_after_edit = self.browser.find_element_by_link_text(
            self.name_professor + 'Edit')
        professor_name_link_after_edit.click()
        list_professor_info = self.browser.find_elements_by_tag_name('p')
        self.assertEqual(list_professor_info[1].text, 'Member ID: 0')
        self.assertEqual(list_professor_info[2].text, 'Office: None')
        self.assertEqual(list_professor_info[3].text, 'Email: None')
        self.assertEqual(list_professor_info[4].text, 'Phone Number: 0')
        self.assertEqual(list_professor_info[5].text, 'CellPhone Number: 0')
        self.assertEqual(list_professor_info[6].text, 'Id Department: None')

    def test_delete_professor(self):
        professor = Professor(self.name_professor)
        professor.store()
        open_page(self.browser, '/interface/professor', self.live_server_url)
        professor_name_link = self.browser.find_element_by_link_text(
            self.name_professor)
        professor_name_link.click()
        self.assertIn('Interface - Professor Detail', self.browser.title)
        button_delete = self.browser.find_element_by_name('deletar')
        button_delete.click()
        alert = self.browser.switch_to.alert
        alert.accept()
        self.assertIn('Interface - Professor', self.browser.title)
        professor_name_after_delete = self.browser.find_elements_by_tag_name(
            'a')
        names = [link.text for link in professor_name_after_delete]
        self.assertNotIn(self.name_professor, names)
Exemplo n.º 20
0
    wd.get("http://localhost/addressbook/group.php")
    wd.find_element_by_name("pass").click()
    wd.find_element_by_name("pass").send_keys("\\undefined")
    wd.find_element_by_xpath("//form[@id='LoginForm']/input[3]").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("rytyrtytry")
    wd.find_element_by_name("group_header").click()
    wd.find_element_by_name("group_header").send_keys("\\89")
    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("trytryrty")
    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()
    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("tryrtytrytry")
    wd.find_element_by_name("submit").click()
    wd.find_element_by_link_text("group page").click()
    wd.find_element_by_link_text("Logout").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").send_keys("\\undefined")
finally:
    wd.quit()
    if not success:
        raise Exception("Test failed.")
Exemplo n.º 21
0
Arquivo: tests.py Projeto: ericls/niji
class TopicOrderingTest(LiveServerTestCase):

    def setUp(self):
        self.browser = WebDriver()
        self.browser.implicitly_wait(3)
        self.n1 = Node.objects.create(
            title='TestNodeOne',
            description='The first test node'
        )
        self.u1 = User.objects.create_user(
            username='******', email='*****@*****.**', password='******'
        )
        # Create 99 topics
        for i in range(1, 100):
            setattr(
                self,
                't%s' % i,
                Topic.objects.create(
                    title='Test Topic %s' % i,
                    user=self.u1,
                    content_raw='This is test topic __%s__' % i,
                    node=self.n1
                )
            )

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

    def test_default_ordering_without_settings(self):
        self.browser.get(self.live_server_url+reverse("niji:index"))
        first_topic_title = self.browser.find_element_by_class_name(
            "entry-link"
        ).text
        self.assertEqual(first_topic_title, self.t99.title)
        Post.objects.create(
            topic=self.t1,
            content_raw='reply to post __1__',
            user=self.u1,
        )
        self.browser.get(self.browser.current_url)
        first_topic_title = self.browser.find_element_by_class_name(
            "entry-link"
        ).text
        self.assertEqual(first_topic_title, self.t1.title)

    @override_settings(NIJI_DEFAULT_TOPIC_ORDERING="-pub_date")
    def test_default_ordering_with_settings(self):
        self.browser.get(self.live_server_url+reverse("niji:index"))
        first_topic_title = self.browser.find_element_by_class_name(
            "entry-link"
        ).text
        self.assertEqual(first_topic_title, self.t99.title)
        Post.objects.create(
            topic=self.t1,
            content_raw='reply to post __1__',
            user=self.u1,
        )
        self.browser.get(self.browser.current_url)
        first_topic_title = self.browser.find_element_by_class_name(
            "entry-link"
        ).text
        self.assertEqual(first_topic_title, self.t99.title)

    def test_user_specified_ordering_last_replied(self):
        self.browser.get(self.live_server_url+reverse("niji:index"))
        self.browser.find_element_by_link_text(
            "Last Replied"
        ).click()
        first_topic_title = self.browser.find_element_by_class_name(
            "entry-link"
        ).text
        self.assertEqual(first_topic_title, self.t99.title)

    def test_user_specified_ordering_pub_date(self):
        Post.objects.create(
            topic=self.t1,
            content_raw='reply to post __1__',
            user=self.u1,
        )
        self.browser.get(self.live_server_url+reverse("niji:index"))
        self.browser.find_element_by_link_text(
            "Topic Date"
        ).click()
        first_topic_title = self.browser.find_element_by_class_name(
            "entry-link"
        ).text
        self.assertEqual(first_topic_title, self.t99.title)

    def test_user_specified_ordering_last_replied_pagination(self):
        self.browser.get(self.live_server_url+reverse("niji:index"))
        self.browser.find_element_by_link_text(
            "Last Replied"
        ).click()
        res = self.client.get(self.browser.current_url)
        request = res.wsgi_request
        self.assertEqual(request.GET.get("order"), "-last_replied")
        self.browser.find_element_by_link_text("»").click()
        res = self.client.get(self.browser.current_url)
        request = res.wsgi_request
        self.assertEqual(request.GET.get("order"), "-last_replied")

    def test_user_specified_ordering_node_view(self):
        Post.objects.create(
            topic=self.t1,
            content_raw='reply to post __1__',
            user=self.u1,
        )
        self.browser.get(
            self.live_server_url+reverse(
                "niji:node",
                kwargs={"pk": self.n1.pk}
            )
        )
        self.browser.find_element_by_link_text(
            "Topic Date"
        ).click()
        first_topic_title = self.browser.find_element_by_class_name(
            "entry-link"
        ).text
        self.assertEqual(first_topic_title, self.t99.title)

    def test_user_specified_ordering_search_view(self):
        Post.objects.create(
            topic=self.t1,
            content_raw='reply to post __1__',
            user=self.u1,
        )
        self.browser.get(
            self.live_server_url+reverse(
                "niji:search",
                kwargs={"keyword": "test"}
            )
        )
        self.browser.find_element_by_link_text(
            "Topic Date"
        ).click()
        first_topic_title = self.browser.find_element_by_class_name(
            "entry-link"
        ).text
        self.assertEqual(first_topic_title, self.t99.title)
Exemplo n.º 22
0
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("https://rippletrade.com/")
    wd.find_element_by_link_text("Sign Up").click()
    wd.find_element_by_id("register_username").click()
    wd.find_element_by_id("register_username").clear()
    wd.find_element_by_id("register_username").send_keys("yuiyoxoq")
    wd.find_element_by_id("register_password").click()
    wd.find_element_by_id("register_password").clear()
    wd.find_element_by_id("register_password").send_keys("b1zd3vf0r3v3r")
    wd.find_element_by_id("register_password2").click()
    wd.find_element_by_id("register_password2").clear()
    wd.find_element_by_id("register_password2").send_keys("b1zd3vf0r3v3r")
    wd.find_element_by_id("register_email").click()
    wd.find_element_by_id("register_email").clear()
    wd.find_element_by_id("register_email").send_keys("*****@*****.**")
    if not wd.find_element_by_id("terms").is_selected():
        wd.find_element_by_id("terms").click()
    wd.find_element_by_xpath("//div[@id='t-register']//button[.='Sign UpMigrate Account']").click()
Exemplo n.º 23
0
class EntrySeleleniumTests(StaticLiveServerTestCase):
    """Selenium tests for the entry form"""
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        if not settings.DEBUG:
            settings.DEBUG = True

    def setUp(self):
        """Handles login and things"""
        call_command('flush', interactive=False, verbosity=0)  # Clears db
        call_command('loaddata', 'groups', commit=False, verbosity=0)
        call_command('loaddata', 'school', commit=False, verbosity=0)
        call_command('loaddata', 'permissions', commit=False, verbosity=0)
        call_command('loaddata', 'auth_users', commit=False, verbosity=0)
        call_command('loaddata', 'student', commit=False, verbosity=0)
        call_command('loaddata', 'advisor', commit=False, verbosity=0)
        call_command('loaddata', 'coordinator', commit=False, verbosity=0)
        call_command('loaddata', 'activityoptions', commit=False, verbosity=0)
        call_command('loaddata',
                     'learningobjectiveoptions',
                     commit=False,
                     verbosity=0)
        call_command('loaddata', 'sample_entries', commit=False, verbosity=0)
        self.selenium = WebDriver()
        self.selenium.set_window_size(1024, 800)
        self.selenium.get('{0}/{1}'.format(self.live_server_url, ''))
        self.selenium.find_element_by_xpath(
            '//*[@id="djHideToolBarButton"]').click()
        self.selenium.implicitly_wait(10)
        self.selenium.find_element_by_link_text('Login').click()
        # Click on the student button in the gateway
        self.selenium.find_element_by_xpath(
            '/html/body/center/md-content/div/div/div[1]/a').click()
        self.selenium\
            .find_element_by_xpath("//img[@src='/static/journal/activities/img"
                                   "/journal_sign.png']")
        super()

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

    def test_text_entry(self):
        """Test to ensure that a student can add a text entry"""
        # Click on the first activity box: Walking around the block
        self.selenium.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div/div[1]/div/div[3]/a/div').click()
        self.selenium.find_element_by_link_text('Add an entry').click()
        # The following has 2 matching: Just walking and Adding entry...block
        header_text = self.selenium.find_elements_by_tag_name('h3')[1].text
        self.assertTrue(
            'Adding entry for Walking around the block!' in header_text)
        # Switching to iframe focus
        self.selenium.switch_to_frame(
            self.selenium.find_element_by_id('id_entry_iframe'))
        # Insert text
        entry = 'I think I will bring my cat out next time.'
        self.selenium.find_element_by_class_name('note-editable')\
            .send_keys(entry)
        # Switch back out of the iframe.
        self.selenium.switch_to_default_content()
        # Click on the submit button
        self.selenium.find_element_by_class_name('btn-success').click()
        # Ensure that we are back on the entries page.
        self.selenium.find_element_by_link_text('Add an entry')
        # Ensure that entry exists as the first box on the page.
        box_text = self.selenium.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div[2]/div[1]/a/div').text
        self.assertTrue(entry in box_text)

    def test_image_entry(self):
        """Test to ensure that a student can add an image entry"""
        # Click on the first activity box: Walking around the block
        self.selenium.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div/div[1]/div/div[3]/a/div').click()
        self.selenium.find_element_by_link_text('Add an entry').click()
        # The following has 2 matching: Just walking and Adding entry...block
        header_text = self.selenium.find_elements_by_tag_name('h3')[1].text
        self.assertTrue(
            'Adding entry for Walking around the block!' in header_text)
        # Switching to iframe focus
        self.selenium.switch_to_frame(
            self.selenium.find_element_by_id('id_entry_iframe'))
        self.selenium.find_element_by_xpath(
            '/html/body/div[2]/div[5]/div[3]/button[2]').click()
        entry = 'http://images.jfdaily.com/jiefang/wenyu/new/201409/W020140919421426345484.jpg'
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[1]/div/div/div[2]/div[2]/input')\
            .send_keys(entry)
        # click on the inset image button
        self.selenium.find_element_by_xpath(
            '/html/body/div[2]/div[2]/div[1]/div/div/div[3]/button').click()
        # Switch back out of the iframe.
        self.selenium.switch_to_default_content()
        # Click on the submit button
        self.selenium.implicitly_wait(10)
        self.selenium.find_element_by_class_name('btn-success').click()
        # Ensure that we are back on the entries page.
        self.selenium.find_element_by_link_text('Add an entry')
        # Ensure that entry exists on the page.
        self.selenium.find_element_by_xpath(
            "//img[@src='http://images.jfdaily.com/jiefang/wenyu/new/201409/W020140919421426345484.jpg']"
        )

    def test_video_entry(self):
        """Test to ensure that a student can add a video entry"""
        # Click on the first activity box: Walking around the block
        self.selenium.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div/div[1]/div/div[3]/a/div').click()
        self.selenium.find_element_by_link_text('Add an entry').click()
        # The following has 2 matching: Just walking and Adding entry...block
        header_text = self.selenium.find_elements_by_tag_name('h3')[1].text
        self.assertTrue(
            'Adding entry for Walking around the block!' in header_text)
        # Switching to iframe focus
        self.selenium.switch_to_frame(
            self.selenium.find_element_by_id('id_entry_iframe'))
        # Insert video
        self.selenium.find_element_by_xpath(
            '/html/body/div[2]/div[5]/div[3]/button[3]').click()
        entry = 'https://www.youtube.com/watch?v=Rk_bV0RJRhs&index=20&list=PLJU_WCB1rA2SFwFy3lEvY_NH23ql1-Cgi'
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[4]/div/div/div[2]/div/input')\
            .send_keys(entry)
        # click on the insert video button
        self.selenium.find_element_by_xpath(
            '/html/body/div[2]/div[2]/div[4]/div/div/div[3]/button').click()
        # Switch back out of the iframe.
        self.selenium.switch_to_default_content()
        # Click on the submit button
        self.selenium.implicitly_wait(10)
        self.selenium.find_element_by_class_name('btn-success').click()
        # Ensure that we are back on the entries page.
        self.selenium.find_element_by_link_text('Add an entry')
        self.selenium.find_element_by_xpath(
            '//iframe[@src="//www.youtube.com/embed/Rk_bV0RJRhs"]')

    def test_image_text_entry(self):
        """Test to ensure that a student can add image+text entries"""
        # Click on the first activity box: Walking around the block
        self.selenium.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div/div[1]/div/div[3]/a/div').click()
        self.selenium.find_element_by_link_text('Add an entry').click()
        # The following has 2 matching: Just walking and Adding entry...block
        header_text = self.selenium.find_elements_by_tag_name('h3')[1].text
        self.assertTrue(
            'Adding entry for Walking around the block!' in header_text)
        # Switching to iframe focus
        self.selenium.switch_to_frame(
            self.selenium.find_element_by_id('id_entry_iframe'))
        # Insert text
        entry = 'I think I will bring my cat out next time with a flower.'
        self.selenium.find_element_by_class_name('note-editable')\
            .send_keys(entry)
        # Insert the image
        self.selenium.find_element_by_xpath(
            '/html/body/div[2]/div[5]/div[3]/button[2]').click()
        image_entry = 'http://images.jfdaily.com/jiefang/wenyu/new/201409/W020140919421426345484.jpg'
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[1]/div/div/div[2]/div[2]/input')\
            .send_keys(image_entry)
        # Click on the insert image button
        self.selenium.find_element_by_xpath(
            '/html/body/div[2]/div[2]/div[1]/div/div/div[3]/button').click()
        # Switch back out of the iframe.
        self.selenium.switch_to_default_content()
        # Click on the submit button
        self.selenium.implicitly_wait(10)
        self.selenium.find_element_by_class_name('btn-success').click()
        # Ensure that we are back on the entries page.
        self.selenium.find_element_by_link_text('Add an entry')
        # Ensure the text is on the entries page
        box_text = self.selenium.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div[2]/div[1]/a/div').text
        self.assertTrue(entry in box_text)
        # Ensure the image is on the entries page
        self.selenium.find_element_by_xpath(
            "//img[@src='http://images.jfdaily.com/jiefang/wenyu/new/201409/W020140919421426345484.jpg']"
        )

    def test_video_text_entry(self):
        """Test to ensure that a student can add an text+video entry"""
        # Click on the first activity box: Walking around the block
        self.selenium.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div/div[1]/div/div[3]/a/div').click()
        self.selenium.find_element_by_link_text('Add an entry').click()
        # The following has 2 matching: Just walking and Adding entry...block
        header_text = self.selenium.find_elements_by_tag_name('h3')[1].text
        self.assertTrue(
            'Adding entry for Walking around the block!' in header_text)
        # Switching to iframe focus
        self.selenium.switch_to_frame(
            self.selenium.find_element_by_id('id_entry_iframe'))
        # Insert text
        entry = 'I think I will bring my cat out next time.'
        self.selenium.find_element_by_class_name('note-editable')\
            .send_keys(entry)
        # Insert video
        self.selenium.find_element_by_xpath(
            '/html/body/div[2]/div[5]/div[3]/button[3]').click()
        video_entry = 'https://www.youtube.com/watch?v=Rk_bV0RJRhs&index=20&list=PLJU_WCB1rA2SFwFy3lEvY_NH23ql1-Cgi'
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[4]/div/div/div[2]/div/input')\
            .send_keys(video_entry)
        # Click on the insert video button
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[4]/div/div/div[3]/button')\
            .click()
        # Switch back out of the iframe.
        self.selenium.switch_to_default_content()
        # Click on the submit button
        self.selenium.find_element_by_class_name('btn-success').click()
        # Ensure that we are back on the entries page.
        self.selenium.find_element_by_link_text('Add an entry')
        # Ensure that entry exists as the first box on the page.
        box_text = self.selenium.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div[1]/a/div')\
            .text
        self.assertTrue(entry in box_text)
        self.selenium.find_element_by_xpath(
            '//iframe[@src="//www.youtube.com/embed/Rk_bV0RJRhs"]')

    def test_text_image_video_entry(self):
        """Test to ensure that a student can add an text+image+video entry"""
        # Click on the first activity box: Walking around the block
        self.selenium.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div/div[1]/div/div[3]/a/div').click()
        self.selenium.find_element_by_link_text('Add an entry').click()
        # The following has 2 matching: Just walking and Adding entry...block
        header_text = self.selenium.find_elements_by_tag_name('h3')[1].text
        self.assertTrue(
            'Adding entry for Walking around the block!' in header_text)
        # Switching to iframe focus
        self.selenium.switch_to_frame(
            self.selenium.find_element_by_id('id_entry_iframe'))
        # Insert text
        text_entry = 'I think I will bring my cat out next time.'
        self.selenium.find_element_by_class_name('note-editable')\
            .send_keys(text_entry)
        # Insert image button
        self.selenium.find_element_by_xpath(
            '/html/body/div[2]/div[5]/div[3]/button[2]').click()
        image_entry = 'http://images.jfdaily.com/jiefang/wenyu/new/201409/W020140919421426345484.jpg'
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[1]/div/div/div[2]/div[2]/input')\
            .send_keys(image_entry)
        # Click on the inset image button
        self.selenium.find_element_by_xpath(
            '/html/body/div[2]/div[2]/div[1]/div/div/div[3]/button').click()
        # Insert video button
        self.selenium.find_element_by_xpath(
            '/html/body/div[2]/div[5]/div[3]/button[3]').click()
        video_entry = 'https://www.youtube.com/watch?v=Rk_bV0RJRhs&index=20&list=PLJU_WCB1rA2SFwFy3lEvY_NH23ql1-Cgi'
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[4]/div/div/div[2]/div/input')\
            .send_keys(video_entry)
        # Click on the insert video button
        self.selenium.find_element_by_xpath(
            '/html/body/div[2]/div[2]/div[4]/div/div/div[3]/button').click()
        # Switch back out of the iframe.
        self.selenium.switch_to_default_content()
        # Click on the submit button
        self.selenium.find_element_by_class_name('btn-success').click()
        # Ensure that we are back on the entries page.
        self.selenium.find_element_by_link_text('Add an entry')
        # Ensure that entry exists as the first box on the page.
        box_text = self.selenium.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div[2]/div[1]/a/div').text
        self.assertTrue(text_entry in box_text)
        self.selenium.find_element_by_xpath(
            "//img[@src='http://images.jfdaily.com/jiefang/wenyu/new/201409/W020140919421426345484.jpg']"
        )
        self.selenium.find_element_by_xpath(
            '//iframe[@src="//www.youtube.com/embed/Rk_bV0RJRhs"]')

    def test_delete_entry(self):
        """Test to ensure that a student can delete an entry"""
        # Click on the first activity box: Walking around the block
        self.selenium.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div/div[1]/div/div[3]/a/div').click()
        self.selenium.find_element_by_link_text('Add an entry').click()
        # The following has 2 matching: Just walking and Adding entry...block
        header_text = self.selenium.find_elements_by_tag_name('h3')[1].text
        self.assertTrue(
            'Adding entry for Walking around the block!' in header_text)
        # Switching to iframe focus
        self.selenium.switch_to_frame(
            self.selenium.find_element_by_id('id_entry_iframe'))
        # Insert text
        text_entry = 'I think I will bring my cat out next time.'
        self.selenium.find_element_by_class_name('note-editable')\
            .send_keys(text_entry)
        # Insert image button
        self.selenium.find_element_by_xpath(
            '/html/body/div[2]/div[5]/div[3]/button[2]').click()
        image_entry = 'http://images.jfdaily.com/jiefang/wenyu/new/201409/W020140919421426345484.jpg'
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[1]/div/div/div[2]/div[2]/input')\
            .send_keys(image_entry)
        # Click on the inset image button
        self.selenium.find_element_by_xpath(
            '/html/body/div[2]/div[2]/div[1]/div/div/div[3]/button').click()
        # Insert video button
        self.selenium.find_element_by_xpath(
            '/html/body/div[2]/div[5]/div[3]/button[3]').click()
        video_entry = 'https://www.youtube.com/watch?v=Rk_bV0RJRhs&index=20&list=PLJU_WCB1rA2SFwFy3lEvY_NH23ql1-Cgi'
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[4]/div/div/div[2]/div/input')\
            .send_keys(video_entry)
        # Click on the insert video button
        self.selenium.find_element_by_xpath(
            '/html/body/div[2]/div[2]/div[4]/div/div/div[3]/button').click()
        # Switch back out of the iframe.
        self.selenium.switch_to_default_content()
        # Click on the submit button
        self.selenium.find_element_by_class_name('btn-success').click()
        # Ensure that we are back on the entries page.
        self.selenium.find_element_by_link_text('Add an entry')
        # Ensure that entry exists as the first box on the page.
        box_text = self.selenium.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div[2]/div[1]/a/div').text
        self.assertTrue(text_entry in box_text)
        self.selenium.find_element_by_xpath(
            "//img[@src='http://images.jfdaily.com/jiefang/wenyu/new/201409/W020140919421426345484.jpg']"
        )
        self.selenium.find_element_by_xpath(
            '//iframe[@src="//www.youtube.com/embed/Rk_bV0RJRhs"]')
        # Click on the entry that was created
        self.selenium.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div[2]/div[1]/a').click()
        # Click on the delete button
        self.selenium.find_element_by_class_name('btn-danger').click()
        self.selenium.find_element_by_xpath(
            '//*[@id="delete-modal"]/div/div/div[3]/a').click()
        # Ensure that we are back on the entries page.
        self.selenium.find_element_by_link_text('Add an entry')
        # Ensure that the entry created is no longer on the entries page
        main_text = self.selenium.find_element_by_class_name('main').text
        # Check for text
        self.assertFalse(text_entry in main_text)
        # Check for image
        image_entry_xpath = "//img[@src='http://images.jfdaily.com/jiefang/wenyu/new/201409/W020140919421426345484.jpg']"
        self.assertFalse(image_entry_xpath in main_text)
        # Check for video
        video_entry_xpath = '//iframe[@src="//www.youtube.com/embed/Rk_bV0RJRhs"]'
        self.assertFalse(video_entry_xpath in main_text)
Exemplo n.º 24
0
class ActivitySeleleniumTests(StaticLiveServerTestCase):
    """Selenium tests for the activity page"""
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        if not settings.DEBUG:
            settings.DEBUG = True
        if not settings.TESTING:
            settings.TESTING = True

    def setUp(self):
        """Handles login and things"""
        call_command('flush', interactive=False, verbosity=0)  # Clears db
        call_command('loaddata', 'groups', commit=False, verbosity=0)
        call_command('loaddata', 'school', commit=False, verbosity=0)
        call_command('loaddata', 'permissions', commit=False, verbosity=0)
        call_command('loaddata', 'auth_users', commit=False, verbosity=0)
        call_command('loaddata', 'student', commit=False, verbosity=0)
        call_command('loaddata', 'advisor', commit=False, verbosity=0)
        call_command('loaddata', 'coordinator', commit=False, verbosity=0)
        call_command('loaddata', 'activityoptions', commit=False, verbosity=0)
        call_command('loaddata',
                     'learningobjectiveoptions',
                     commit=False,
                     verbosity=0)
        call_command('loaddata', 'sample_entries', commit=False, verbosity=0)
        self.selenium = WebDriver()
        self.selenium.set_window_size(1024, 800)
        self.selenium.get('{0}/{1}'.format(self.live_server_url, ''))
        self.selenium.find_element_by_xpath(
            '//*[@id="djHideToolBarButton"]').click()
        self.selenium.implicitly_wait(10)
        self.selenium.find_element_by_link_text('Login').click()
        # Click on the student button in the gateway
        self.selenium.find_element_by_xpath(
            '/html/body/center/md-content/div/div/div[1]/a').click()
        self.selenium\
            .find_element_by_xpath("//img[@src='/static/journal/activities/img"
                                   "/journal_sign.png']")
        super()

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

    def test_activity_form_back(self):
        """make sure the back button works"""
        self.selenium.find_element_by_xpath(
            "/html/body/div[1]/div[2]/div/div[1]/div/div[2]/div/a").click()
        self.selenium.find_element_by_name('activity_name').send_keys(
            'Walking the cat')
        self.selenium.find_element_by_name('activity_description').send_keys(
            'Walking the cat around the neighborhood')
        self.selenium.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div[1]/form/div[2]/div[2]/input'
        ).send_keys('02/07/1990')
        self.selenium.find_element_by_xpath(
            '//*[@id="id_activity_type"]/li[2]/label').click()
        self.selenium.find_element_by_xpath(
            '//*[@id="id_activity_type"]/li[3]/label').click()
        self.selenium.find_element_by_xpath(
            '//*[@id="id_learned_objective"]/li[6]/label').click()
        self.selenium.find_element_by_name('activity_adviser').send_keys('Cat')
        self.selenium.find_element_by_name('advisor_phone').send_keys(
            '1234567890')
        self.selenium.find_element_by_name('advisor_email').send_keys(
            '*****@*****.**')
        self.selenium.find_element_by_link_text('Back').click()
        self.selenium\
            .find_element_by_xpath("//img[@src='/static/journal/activities/img"
                                   "/journal_sign.png']")

    def test_activity_form_error(self):
        """Tests to check errors on the activity form"""
        self.selenium.find_element_by_xpath(
            "/html/body/div[1]/div[2]/div/div[1]/div/div[2]/div/a").click()
        # self.selenium.find_element_by_name('activity_name').send_keys('')
        self.selenium.find_element_by_name('activity_description').send_keys(
            'Walking with huahua around the neighborhood')
        self.selenium.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div[1]/form/div[2]/div[2]/input'
        ).send_keys('02/07/1990')
        self.selenium.find_element_by_xpath(
            '//*[@id="id_activity_type"]/li[2]/label').click()
        self.selenium.find_element_by_xpath(
            '//*[@id="id_activity_type"]/li[3]/label').click()
        self.selenium.find_element_by_xpath(
            '//*[@id="id_learned_objective"]/li[6]/label').click()
        self.selenium.find_element_by_name('activity_adviser').send_keys('Cat')
        self.selenium.find_element_by_name('advisor_phone').send_keys(
            '1234567890')
        self.selenium.find_element_by_name('advisor_email').send_keys(
            '*****@*****.**')
        self.selenium.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div[1]/form/div[6]/div/input').click()
        self.selenium.find_element_by_name('activity_description').text

    def test_activity_form(self):
        """Tests to ensure that activities page has all necessary elements."""
        self.selenium.find_element_by_xpath(
            "/html/body/div[1]/div[2]/div/div[1]/div/div[2]/div/a").click()
        self.selenium.find_element_by_name('activity_name').send_keys(
            'Walking the cat')
        self.selenium.find_element_by_name('activity_description').send_keys(
            'Walking the cat around the neighborhood')
        self.selenium.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div[1]/form/div[2]/div[2]/input'
        ).send_keys('02/07/1990')
        self.selenium.find_element_by_xpath(
            '//*[@id="id_activity_type"]/li[2]/label').click()
        self.selenium.find_element_by_xpath(
            '//*[@id="id_activity_type"]/li[3]/label').click()
        self.selenium.find_element_by_xpath(
            '//*[@id="id_learned_objective"]/li[6]/label').click()
        self.selenium.find_element_by_name('activity_adviser').send_keys('Cat')
        self.selenium.find_element_by_name('advisor_phone').send_keys(
            '1234567890')
        self.selenium.find_element_by_name('advisor_email').send_keys(
            '*****@*****.**')
        self.selenium.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div[1]/form/div[6]/div/input').click()
        self.selenium\
            .find_element_by_xpath("//img[@src='/static/journal/activities/img"
                                   "/journal_sign.png']")
        body_text = self.selenium.find_element_by_tag_name('body').text
        self.assertTrue('Walking the cat' in body_text)
        self.assertTrue('Walking the cat around the neighborhood' in body_text)
Exemplo n.º 25
0
class SeleniumTests(LiveServerTestCase):
    """Base class for all Selenium test classes to inherit from"""

    @classmethod
    def setUpClass(self):
        self.selenium = WebDriver()
        self.selenium.implicitly_wait(3)
        super(SeleniumTests, self).setUpClass()

    @classmethod
    def tearDownClass(self):
        self.selenium.quit()
        super(SeleniumTests, self).tearDownClass()

    def setUp(self):
        # Create a test user and admin account
        self.user_name = 'SeleniumTestUser'
        self.user_pass = '******'
        if User.objects.filter(username=self.user_name).count() == 0:
            User.objects.create_user(self.user_name, '', self.user_pass).save()

        self.admin_name = 'SeleniumAdministrativeUser'
        self.admin_pass = '******'
        if User.objects.filter(username=self.admin_name).count() == 0:
            User.objects.create_superuser(self.admin_name, '', self.admin_pass).save()

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

    def link_text_exists(self, link_text):
        try:
            self.selenium.find_element_by_link_text(link_text)
        except NoSuchElementException:
            return False
        return True

    def xpath_exists(self, xpath):
        try:
            self.selenium.find_element_by_xpath(xpath)
        except NoSuchElementException:
            return False
        return True

    def element_with_selector_exists(self, selector):
        try:
            self.selenium.find_element_by_css_selector(selector)
        except NoSuchElementException:
            return False
        return True

    def text_exists(self, text, xpath="//body"):
        try:
            element = self.selenium.find_element_by_xpath(xpath)
        except NoSuchElementException:
            return False

        if text in element.text:
            return True
        else:
            return False

    def login(self, username, password):
        # Go to the login page and try logging in with the provided credentials
        self.selenium.get('%s' % self.live_server_url)
        self.selenium.find_element_by_link_text('Log in').click()
        username_input = self.selenium.find_element_by_name('username')
        username_input.send_keys(username)
        password_input = self.selenium.find_element_by_name('password')
        password_input.send_keys(password)
        self.selenium.find_element_by_class_name('submit').click()

    def create_items_and_requests(self, x):
        # Creates x number of items and requests
        for i in xrange(x):
            self.item = G(Item)
            self.request = G(Request, item=self.item)

    def create_generic_item(self):
        # Quick helper in the absence of fixtures
        item = G(Item, local_num=9999, part_class='parts class',
                 location='cart 8', description='test item', cfi='never',
                 company='A Business', part_num='X9X9', serial_num='8A',
                 asset_num='sample_num', notes='Testing')
        return item
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://www.jared.com/en/jaredstore/")
    wd.find_element_by_link_text("Engagement").click()
    if not ("Engagement" in wd.find_element_by_tag_name("html").text):
        success = False
        print("verifyTextPresent failed")
    if not wd.find_element_by_id("facet_checkbox8").is_selected():
        wd.find_element_by_id("facet_checkbox8").click()
    wd.find_element_by_id("view-more").click()
    wd.find_element_by_link_text("VAULT VALUE
                        			
								
							
                        
							Vera Wang LOVE 1 Carat tw Diamonds 14K White Gold Ring 
								
							 
						
Exemplo n.º 27
0
class IntegrationTests(StaticLiveServerTestCase):
    """Integration tests by using the Selenium web drivers"""
    fixtures = ['test_data.json']

    def setUp(self):
        self.driver = WebDriver()

    def login_player(self):
        """Helper function for logging in as a player"""
        self.driver.get('%s%s' % (self.live_server_url, '/login'))

        username = self.driver.find_element_by_id('id_username')
        password = self.driver.find_element_by_id('id_password')
        submit = self.driver.find_element_by_tag_name('button')

        username.send_keys('player')
        password.send_keys('player')

        submit.click()

    def login_developer(self):
        """Helper function for logging in as a developer"""
        self.driver.get('%s%s' % (self.live_server_url, '/login'))

        username = self.driver.find_element_by_id('id_username')
        password = self.driver.find_element_by_id('id_password')
        submit = self.driver.find_element_by_tag_name('button')

        username.send_keys('developer')
        password.send_keys('developer')

        submit.click()

    def test_login(self):
        """Test that logging in works properly"""
        self.login_player()

        assert 'player Account' in self.driver.page_source

    def test_registration(self):
        """
        Test that registration completes, a verification email notification is sent and that
        verification works
        """
        self.driver.get('%s%s' % (self.live_server_url, '/register'))

        first_name = self.driver.find_element_by_id('id_first_name')
        last_name = self.driver.find_element_by_id('id_last_name')
        username = self.driver.find_element_by_id('id_username')
        email = self.driver.find_element_by_id('id_email')
        password1 = self.driver.find_element_by_id('id_password')
        password2 = self.driver.find_element_by_id('id_password1')
        submit = self.driver.find_element_by_tag_name('button')

        first_name.send_keys('Selenium')
        last_name.send_keys('Tester')
        username.send_keys('selenium')
        email.send_keys('*****@*****.**')
        password1.send_keys('qwerty')
        password2.send_keys('qwerty')

        submit.click()

        #Check that the user is not active but email is supposedly sent
        test_user = User.objects.get(username="******")
        assert 'User successfully created, verification email sent!' in self.driver.page_source
        self.assertEqual(test_user.is_active, False)

        #Enter verification bytes and check that the user has been activated
        verification_bytes = test_user.type.verification_bytes
        self.driver.get('%s%s%s' % (self.live_server_url, '/user_verification/',
                                    verification_bytes))
        assert 'User selenium has been verified. Please login.' in self.driver.page_source
        self.assertEqual(User.objects.get(username="******").is_active, True)

    def test_purchasing_game(self):
        """Tests that game can be purchased"""
        self.login_player()
        self.driver.get('%s%s' % (self.live_server_url, '/gamestorepage/3'))

        buy_button = self.driver.find_element_by_xpath("//input[@type='submit']")
        buy_button.click()

        confirm_button = self.driver.find_element_by_xpath("//button[text()='Pay']")
        confirm_button.click()

        assert 'has now been added to your game list!' in self.driver.page_source

    def test_editing_game(self):
        """Tests that game details can be edited by navigating through my games"""
        self.login_developer()
        self.driver.get('%s%s' % (self.live_server_url, '/mygames'))

        game_entry = self.driver.find_element_by_class_name('game-list-container')
        game_entry.click()

        edit_button = self.driver.find_element_by_link_text('Edit')
        edit_button.click()

        modify_button = self.driver.find_element_by_xpath("//button[text()='Modify']")
        game_name = self.driver.find_element_by_id('id_game_name')
        game_name.clear()
        game_name.send_keys('New game name')

        modify_button.click()

        assert 'New game name details have been updated.' in self.driver.page_source

    def test_playing_game(self):
        """Test playing, acquiring score, submitting the score and that score is saved"""
        self.login_player()
        self.driver.get('%s%s' % (self.live_server_url, '/boughtgames'))

        game_entry = self.driver.find_elements_by_class_name('game-list-container')[1]
        game_entry.click()

        play_button = self.driver.find_elements_by_link_text('Play')[1]
        play_button.click()

        assert 'Test Game' in self.driver.page_source

        self.driver.switch_to.frame(self.driver.find_element_by_id('gameFrame'))
        add_score_button = self.driver.find_element_by_id('add_points')

        #Click the button 5 times totaling 50 score
        add_score_button.click()
        add_score_button.click()
        add_score_button.click()
        add_score_button.click()
        add_score_button.click()

        submit_score_button = self.driver.find_element_by_id('submit_score')
        submit_score_button.click()

        self.driver.get('%s%s' % (self.live_server_url, '/boughtgames'))
        game_entry = self.driver.find_elements_by_class_name('game-list-container')[1]
        game_entry.click()

        game_table = self.driver.find_element_by_xpath(
            '(//table[@class="game-list-stats"])[2]//tr[2]')
        self.assertEqual(game_table.text, 'Personal highscore: 50')

    def tearDown(self):
        self.driver.quit()
class PollsTest(LiveServerTestCase):

    def setUp(self):

        user = User()
        user.username = "******"
        user.email = "*****@*****.**"
        user.set_password("adm1n")
        user.is_active = True
        user.is_superuser = True
        user.is_staff = True
        user.save()
        
        self.browser = WebDriver()
        self.browser.implicitly_wait(3)
    
    def tearDown(self):
        self.browser.quit()

    def test_can_create_new_poll_via_admin_site(self):
        # Gertrude opens her web browser, and goes to the admin page
        self.browser.get(self.live_server_url + '/admin/')

        # She sees the familiar 'Django administration' heading
        body = self.browser.find_element_by_tag_name('body')
        self.assertIn('Django administration', \
                          body.find_element_by_id("header").text)

        # She types in her username and passwords and hits return
        username_field = self.browser.find_element_by_name('username')
        username_field.send_keys('admin')

        password_field = self.browser.find_element_by_name('password')
        password_field.send_keys('adm1n')

        password_field.send_keys(Keys.RETURN)

        # her username and password are accepted, and she is taken to
        # the Site Administration page
        body = self.browser.find_element_by_tag_name('body')
        self.assertIn('Site administration', body.text)

        # She now sees a couple of hyperlink that says "Polls"
        polls_links = self.browser.find_elements_by_link_text('Polls')
        self.assertEquals(len(polls_links), 2)

        # The second one looks more exciting, so she clicks it
        polls_links[1].click()

        # She is taken to the polls listing page, which shows she has
        # no polls yet
        body = self.browser.find_element_by_tag_name('body')
        self.assertIn('0 polls', body.text)

        # She sees a link to 'add' a new poll, so she clicks it
        new_poll_link = self.browser.find_element_by_link_text('Add poll')
        new_poll_link.click()

        # She sees some input fields for "Question" and "Date published"
        body = self.browser.find_element_by_tag_name('body')
        self.assertIn('Question:', body.text)
        self.assertIn('Date published:', body.text)

        # She types in an interesting question for the Poll
        question_field = self.browser.find_element_by_name('question')
        question_field.send_keys("How awesome is Test-Driven Development?")

        # She sets the date and time of publication - it'll be a new year's
        # poll!
        date_field = self.browser.find_element_by_name('pub_date_0')
        date_field.send_keys('01/01/12')
        time_field = self.browser.find_element_by_name('pub_date_1')
        time_field.send_keys('00:00')

        # Gertrude clicks the save button
        save_button = self.browser.find_element_by_css_selector("input[value='Save']")
        save_button.click()
            
        # She is returned to the "Polls" listing, where she can see her
        # new poll, listed as a clickable link
        new_poll_links = self.browser.find_elements_by_link_text(
                "How awesome is Test-Driven Development?"
        )

        self.assertEquals(len(new_poll_links), 1)
Exemplo n.º 29
0
class ProfessorTest(LiveServerTestCase):
    
    def setUp(self):
        self.browser = WebDriver()
        self.browser.implicitly_wait(1)
        create_user_and_login(self.browser, self.live_server_url,'john','johnpassword','*****@*****.**')
        self.name_professor = 'teste'

    def tearDown(self):
        [professor.delete() for professor in Professor.find()]
        self.browser.quit()
        
    def create_professor(self,professor_name):
        open_page(self.browser, '/interface/professor', self.live_server_url)
        button_create_professor = self.browser.find_element_by_name('criar')
        button_create_professor.click()
        self.assertIn('Interface - Professor Create', self.browser.title)
        form_name = self.browser.find_element_by_id('id_name')
        form_name.send_keys(professor_name)
        form_memberId = self.browser.find_element_by_id('id_memberId')
        form_memberId.send_keys('00000')
        form_office = self.browser.find_element_by_id('id_office')
        form_office.send_keys('0')
        form_email = self.browser.find_element_by_id('id_email')
        form_email.send_keys('0')
        form_phoneNumber = self.browser.find_element_by_id('id_phoneNumber')
        form_phoneNumber.send_keys('0')
        form_cellphoneNumber = self.browser.find_element_by_id('id_cellphoneNumber')
        form_cellphoneNumber.send_keys('0')
        form_idDepartment = self.browser.find_element_by_id('id_idDepartment')
        form_idDepartment.send_keys('')
        button_submit = self.browser.find_element_by_name('Cadastrar')
        button_submit.click()

    def test_login_to_interface_page(self):
        self.assertIn('Index', self.browser.title)
        link_interface = self.browser.find_element_by_link_text('Interface')
        link_interface.click()
        self.assertIn('Interface', self.browser.title)
        
    def test_login_to_professor_page(self):
        open_page(self.browser, '/interface/', self.live_server_url)
        professor_interface = self.browser.find_element_by_link_text('Professor')
        professor_interface.click()
        self.assertIn('Interface - Professor', self.browser.title)
        
    def test_create_professor(self):
        self.create_professor(self.name_professor)
        open_page(self.browser, '/interface/professor', self.live_server_url)
        professor_name_link = self.browser.find_element_by_link_text(self.name_professor)
        self.assertIsNotNone(professor_name_link)
        
    def test_edit_professor(self):
        professor = Professor(self.name_professor)
        professor.store()
        open_page(self.browser, '/interface/professor', self.live_server_url)
        professor_name_link = self.browser.find_element_by_link_text(self.name_professor)
        professor_name_link.click()
        self.assertIn('Interface - Professor Detail', self.browser.title)
        button_edit = self.browser.find_element_by_name('editar')
        button_edit.click()
        self.assertIn('Interface - Professor Edit', self.browser.title)
        form_name = self.browser.find_element_by_id('id_name')
        form_name.send_keys('Edit')
        form_memberId = self.browser.find_element_by_id('id_memberId')
        form_memberId.send_keys('')
        form_office = self.browser.find_element_by_id('id_office')
        form_office.send_keys('')
        form_email = self.browser.find_element_by_id('id_email')
        form_email.send_keys('')
        form_phoneNumber = self.browser.find_element_by_id('id_phoneNumber')
        form_phoneNumber.send_keys('0')
        form_cellphoneNumber = self.browser.find_element_by_id('id_cellphoneNumber')
        form_cellphoneNumber.send_keys('0')
        form_idDepartment = self.browser.find_element_by_id('id_idDepartment')
        form_idDepartment.send_keys('')
        button_apply = self.browser.find_element_by_name('Aplicar')
        button_apply.click()
        open_page(self.browser, '/interface/professor', self.live_server_url)
        professor_name_link_after_edit = self.browser.find_element_by_link_text(self.name_professor + 'Edit')
        professor_name_link_after_edit.click()
        list_professor_info = self.browser.find_elements_by_tag_name('p')
        self.assertEqual(list_professor_info[1].text, 'Member ID: 0')
        self.assertEqual(list_professor_info[2].text, 'Office: None')
        self.assertEqual(list_professor_info[3].text, 'Email: None')
        self.assertEqual(list_professor_info[4].text, 'Phone Number: 0')
        self.assertEqual(list_professor_info[5].text, 'CellPhone Number: 0')
        self.assertEqual(list_professor_info[6].text, 'Id Department: None')
    
    def test_delete_professor(self):
        professor = Professor(self.name_professor)
        professor.store()
        open_page(self.browser, '/interface/professor', self.live_server_url)
        professor_name_link = self.browser.find_element_by_link_text(self.name_professor)
        professor_name_link.click()
        self.assertIn('Interface - Professor Detail', self.browser.title)
        button_delete = self.browser.find_element_by_name('deletar')
        button_delete.click()
        alert = self.browser.switch_to.alert
        alert.accept()
        self.assertIn('Interface - Professor', self.browser.title)
        professor_name_after_delete = self.browser.find_elements_by_tag_name('a')
        names = [link.text for link in professor_name_after_delete]
        self.assertNotIn(self.name_professor, names)
Exemplo n.º 30
0
Arquivo: tests.py Projeto: astucse/SAS
class TopicOrderingTest(LiveServerTestCase):
    def setUp(self):
        self.browser = WebDriver()
        self.browser.implicitly_wait(3)
        self.n1 = Node.objects.create(title='TestNodeOne',
                                      description='The first test node')
        self.u1 = User.objects.create_user(username='******',
                                           email='*****@*****.**',
                                           password='******')
        # Create 99 topics
        for i in range(1, 100):
            setattr(
                self, 't%s' % i,
                Topic.objects.create(title='Test Topic %s' % i,
                                     user=self.u1,
                                     content_raw='This is test topic __%s__' %
                                     i,
                                     node=self.n1))

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

    def test_default_ordering_without_settings(self):
        self.browser.get(self.live_server_url + reverse("index"))
        first_topic_title = self.browser.find_element_by_class_name(
            "entry-link").text
        self.assertEqual(first_topic_title, self.t99.title)
        Post.objects.create(
            topic=self.t1,
            content_raw='reply to post __1__',
            user=self.u1,
        )
        self.browser.get(self.browser.current_url)
        first_topic_title = self.browser.find_element_by_class_name(
            "entry-link").text
        self.assertEqual(first_topic_title, self.t1.title)

    @override_settings(NIJI_DEFAULT_TOPIC_ORDERING="-pub_date")
    def test_default_ordering_with_settings(self):
        self.browser.get(self.live_server_url + reverse("index"))
        first_topic_title = self.browser.find_element_by_class_name(
            "entry-link").text
        self.assertEqual(first_topic_title, self.t99.title)
        Post.objects.create(
            topic=self.t1,
            content_raw='reply to post __1__',
            user=self.u1,
        )
        self.browser.get(self.browser.current_url)
        first_topic_title = self.browser.find_element_by_class_name(
            "entry-link").text
        self.assertEqual(first_topic_title, self.t99.title)

    def test_user_specified_ordering_last_replied(self):
        self.browser.get(self.live_server_url + reverse("index"))
        self.browser.find_element_by_link_text("Last Replied").click()
        first_topic_title = self.browser.find_element_by_class_name(
            "entry-link").text
        self.assertEqual(first_topic_title, self.t99.title)

    def test_user_specified_ordering_pub_date(self):
        Post.objects.create(
            topic=self.t1,
            content_raw='reply to post __1__',
            user=self.u1,
        )
        self.browser.get(self.live_server_url + reverse("index"))
        self.browser.find_element_by_link_text("Topic Date").click()
        first_topic_title = self.browser.find_element_by_class_name(
            "entry-link").text
        self.assertEqual(first_topic_title, self.t99.title)

    def test_user_specified_ordering_last_replied_pagination(self):
        self.browser.get(self.live_server_url + reverse("index"))
        self.browser.find_element_by_link_text("Last Replied").click()
        res = self.client.get(self.browser.current_url)
        request = res.wsgi_request
        self.assertEqual(request.GET.get("order"), "-last_replied")
        self.browser.find_element_by_link_text("»").click()
        res = self.client.get(self.browser.current_url)
        request = res.wsgi_request
        self.assertEqual(request.GET.get("order"), "-last_replied")

    def test_user_specified_ordering_node_view(self):
        Post.objects.create(
            topic=self.t1,
            content_raw='reply to post __1__',
            user=self.u1,
        )
        self.browser.get(self.live_server_url +
                         reverse("node", kwargs={"pk": self.n1.pk}))
        self.browser.find_element_by_link_text("Topic Date").click()
        first_topic_title = self.browser.find_element_by_class_name(
            "entry-link").text
        self.assertEqual(first_topic_title, self.t99.title)

    def test_user_specified_ordering_search_view(self):
        Post.objects.create(
            topic=self.t1,
            content_raw='reply to post __1__',
            user=self.u1,
        )
        self.browser.get(self.live_server_url +
                         reverse("search", kwargs={"keyword": "test"}))
        self.browser.find_element_by_link_text("Topic Date").click()
        first_topic_title = self.browser.find_element_by_class_name(
            "entry-link").text
        self.assertEqual(first_topic_title, self.t99.title)
# -*- coding: utf-8 -*-
from selenium.webdriver.firefox.webdriver import WebDriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains

success = True
driver = WebDriver()

try:
    driver.set_window_size(1900, 1000)
    driver.get("https://shop.briggsandstratton.com/us/en")
    driver.find_element_by_link_text("Shop Repair Parts Now »").click()

    # This try statement is used to detect the Foresee overlay that pops up at this point in FF
    # Without this, Chrome will not continue to next step as it will error out while waiting
    try:
        wait = WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.LINK_TEXT, "No, thanks")))
        driver.find_element_by_link_text("No, thanks").click()
    except Exception, e:
        print("Foresee not seen here")

    WebDriverWait(driver, 10).until_not(EC.presence_of_element_located((By.ID, "fsrOverlay")))

    driver.find_element_by_id("aarisearch_brands_jl").click()
    wait = WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable((By.XPATH, "//ul[@class='ari-caused-spacer-expand']/li[3]")))
    driver.find_element_by_xpath("//ul[@class='ari-caused-spacer-expand']/li[3]").click()
    driver.find_element_by_id("arisearch_txtSearch").click()
    driver.find_element_by_id("arisearch_txtSearch").clear()
Exemplo n.º 32
0
class EntrySeleleniumTests(StaticLiveServerTestCase):
    """Selenium tests for the entry form"""

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        if not settings.DEBUG:
            settings.DEBUG = True

    def setUp(self):
        """Handles login and things"""
        call_command('flush', interactive=False, verbosity=0)  # Clears db
        call_command('loaddata', 'groups', commit=False, verbosity=0)
        call_command('loaddata', 'school', commit=False, verbosity=0)
        call_command('loaddata', 'permissions', commit=False, verbosity=0)
        call_command('loaddata', 'auth_users', commit=False, verbosity=0)
        call_command('loaddata', 'student', commit=False, verbosity=0)
        call_command('loaddata', 'advisor', commit=False, verbosity=0)
        call_command('loaddata', 'coordinator', commit=False, verbosity=0)
        call_command('loaddata', 'activityoptions', commit=False, verbosity=0)
        call_command('loaddata', 'learningobjectiveoptions', commit=False, verbosity=0)
        call_command('loaddata', 'sample_entries', commit=False, verbosity=0)
        self.selenium = WebDriver()
        self.selenium.set_window_size(1024, 800)
        self.selenium.get('{0}/{1}'.format(self.live_server_url, ''))
        self.selenium.find_element_by_xpath('//*[@id="djHideToolBarButton"]').click()
        self.selenium.implicitly_wait(10)
        self.selenium.find_element_by_link_text('Login').click()
        # Click on the student button in the gateway
        self.selenium.find_element_by_xpath('/html/body/center/md-content/div/div/div[1]/a').click()
        self.selenium\
            .find_element_by_xpath("//img[@src='/static/journal/activities/img"
                                   "/journal_sign.png']")
        super()

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

    def test_text_entry(self):
        """Test to ensure that a student can add a text entry"""
        # Click on the first activity box: Walking around the block
        self.selenium.find_element_by_xpath('/html/body/div[1]/div[2]/div/div[1]/div/div[3]/a/div').click()
        self.selenium.find_element_by_link_text('Add an entry').click()
        # The following has 2 matching: Just walking and Adding entry...block
        header_text = self.selenium.find_elements_by_tag_name('h3')[1].text
        self.assertTrue('Adding entry for Walking around the block!' in header_text)
        # Switching to iframe focus
        self.selenium.switch_to_frame(self.selenium.find_element_by_id('id_entry_iframe'))
        # Insert text
        entry = 'I think I will bring my cat out next time.'
        self.selenium.find_element_by_class_name('note-editable')\
            .send_keys(entry)
        # Switch back out of the iframe.
        self.selenium.switch_to_default_content()
        # Click on the submit button
        self.selenium.find_element_by_class_name('btn-success').click()
        # Ensure that we are back on the entries page.
        self.selenium.find_element_by_link_text('Add an entry')
        # Ensure that entry exists as the first box on the page.
        box_text = self.selenium.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div[1]/a/div').text
        self.assertTrue(entry in box_text)

    def test_image_entry(self):
        """Test to ensure that a student can add an image entry"""
        # Click on the first activity box: Walking around the block
        self.selenium.find_element_by_xpath('/html/body/div[1]/div[2]/div/div[1]/div/div[3]/a/div').click()
        self.selenium.find_element_by_link_text('Add an entry').click()
        # The following has 2 matching: Just walking and Adding entry...block
        header_text = self.selenium.find_elements_by_tag_name('h3')[1].text
        self.assertTrue('Adding entry for Walking around the block!' in header_text)
        # Switching to iframe focus
        self.selenium.switch_to_frame(self.selenium.find_element_by_id('id_entry_iframe'))
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[5]/div[3]/button[2]').click()
        entry = 'http://images.jfdaily.com/jiefang/wenyu/new/201409/W020140919421426345484.jpg'
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[1]/div/div/div[2]/div[2]/input')\
            .send_keys(entry)
        # click on the inset image button
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[1]/div/div/div[3]/button').click()
        # Switch back out of the iframe.
        self.selenium.switch_to_default_content()
        # Click on the submit button
        self.selenium.implicitly_wait(10)
        self.selenium.find_element_by_class_name('btn-success').click()
        # Ensure that we are back on the entries page.
        self.selenium.find_element_by_link_text('Add an entry')
        # Ensure that entry exists on the page.
        self.selenium.find_element_by_xpath("//img[@src='http://images.jfdaily.com/jiefang/wenyu/new/201409/W020140919421426345484.jpg']")

    def test_video_entry(self):
        """Test to ensure that a student can add a video entry"""
        # Click on the first activity box: Walking around the block
        self.selenium.find_element_by_xpath('/html/body/div[1]/div[2]/div/div[1]/div/div[3]/a/div').click()
        self.selenium.find_element_by_link_text('Add an entry').click()
        # The following has 2 matching: Just walking and Adding entry...block
        header_text = self.selenium.find_elements_by_tag_name('h3')[1].text
        self.assertTrue('Adding entry for Walking around the block!' in header_text)
        # Switching to iframe focus
        self.selenium.switch_to_frame(self.selenium.find_element_by_id('id_entry_iframe'))
        # Insert video
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[5]/div[3]/button[3]').click()
        entry = 'https://www.youtube.com/watch?v=Rk_bV0RJRhs&index=20&list=PLJU_WCB1rA2SFwFy3lEvY_NH23ql1-Cgi'
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[4]/div/div/div[2]/div/input')\
            .send_keys(entry)
        # click on the insert video button
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[4]/div/div/div[3]/button').click()
        # Switch back out of the iframe.
        self.selenium.switch_to_default_content()
        # Click on the submit button
        self.selenium.implicitly_wait(10)
        self.selenium.find_element_by_class_name('btn-success').click()
        # Ensure that we are back on the entries page.
        self.selenium.find_element_by_link_text('Add an entry')
        self.selenium.find_element_by_xpath('//iframe[@src="//www.youtube.com/embed/Rk_bV0RJRhs"]')

    def test_image_text_entry(self):
        """Test to ensure that a student can add image+text entries"""
        # Click on the first activity box: Walking around the block
        self.selenium.find_element_by_xpath('/html/body/div[1]/div[2]/div/div[1]/div/div[3]/a/div').click()
        self.selenium.find_element_by_link_text('Add an entry').click()
        # The following has 2 matching: Just walking and Adding entry...block
        header_text = self.selenium.find_elements_by_tag_name('h3')[1].text
        self.assertTrue('Adding entry for Walking around the block!' in header_text)
        # Switching to iframe focus
        self.selenium.switch_to_frame(self.selenium.find_element_by_id('id_entry_iframe'))
        # Insert text
        entry = 'I think I will bring my cat out next time with a flower.'
        self.selenium.find_element_by_class_name('note-editable')\
            .send_keys(entry)
        # Insert the image
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[5]/div[3]/button[2]').click()
        image_entry = 'http://images.jfdaily.com/jiefang/wenyu/new/201409/W020140919421426345484.jpg'
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[1]/div/div/div[2]/div[2]/input')\
            .send_keys(image_entry)
        # Click on the insert image button
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[1]/div/div/div[3]/button').click()
        # Switch back out of the iframe.
        self.selenium.switch_to_default_content()
        # Click on the submit button
        self.selenium.implicitly_wait(10)
        self.selenium.find_element_by_class_name('btn-success').click()
        # Ensure that we are back on the entries page.
        self.selenium.find_element_by_link_text('Add an entry')
        # Ensure the text is on the entries page
        box_text = self.selenium.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div[1]/a/div').text
        self.assertTrue(entry in box_text)
        # Ensure the image is on the entries page
        self.selenium.find_element_by_xpath("//img[@src='http://images.jfdaily.com/jiefang/wenyu/new/201409/W020140919421426345484.jpg']")

    def test_video_text_entry(self):
        """Test to ensure that a student can add an text+video entry"""
        # Click on the first activity box: Walking around the block
        self.selenium.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div/div[1]/div/div[3]/a/div').click()
        self.selenium.find_element_by_link_text('Add an entry').click()
        # The following has 2 matching: Just walking and Adding entry...block
        header_text = self.selenium.find_elements_by_tag_name('h3')[1].text
        self.assertTrue('Adding entry for Walking around the block!' in header_text)
        # Switching to iframe focus
        self.selenium.switch_to_frame(self.selenium.find_element_by_id('id_entry_iframe'))
        # Insert text
        entry = 'I think I will bring my cat out next time.'
        self.selenium.find_element_by_class_name('note-editable')\
            .send_keys(entry)
        # Insert video
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[5]/div[3]/button[3]').click()
        video_entry = 'https://www.youtube.com/watch?v=Rk_bV0RJRhs&index=20&list=PLJU_WCB1rA2SFwFy3lEvY_NH23ql1-Cgi'
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[4]/div/div/div[2]/div/input')\
            .send_keys(video_entry)
        # Click on the insert video button
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[4]/div/div/div[3]/button')\
            .click()
        # Switch back out of the iframe.
        self.selenium.switch_to_default_content()
        # Click on the submit button
        self.selenium.find_element_by_class_name('btn-success').click()
        # Ensure that we are back on the entries page.
        self.selenium.find_element_by_link_text('Add an entry')
        # Ensure that entry exists as the first box on the page.
        box_text = self.selenium.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div[1]/a/div')\
            .text
        self.assertTrue(entry in box_text)
        self.selenium.find_element_by_xpath('//iframe[@src="//www.youtube.com/embed/Rk_bV0RJRhs"]')

    def test_text_image_video_entry(self):
        """Test to ensure that a student can add an text+image+video entry"""
        # Click on the first activity box: Walking around the block
        self.selenium.find_element_by_xpath('/html/body/div[1]/div[2]/div/div[1]/div/div[3]/a/div').click()
        self.selenium.find_element_by_link_text('Add an entry').click()
        # The following has 2 matching: Just walking and Adding entry...block
        header_text = self.selenium.find_elements_by_tag_name('h3')[1].text
        self.assertTrue('Adding entry for Walking around the block!' in header_text)
        # Switching to iframe focus
        self.selenium.switch_to_frame(self.selenium.find_element_by_id('id_entry_iframe'))
        # Insert text
        text_entry = 'I think I will bring my cat out next time.'
        self.selenium.find_element_by_class_name('note-editable')\
            .send_keys(text_entry)
        # Insert image button
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[5]/div[3]/button[2]').click()
        image_entry = 'http://images.jfdaily.com/jiefang/wenyu/new/201409/W020140919421426345484.jpg'
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[1]/div/div/div[2]/div[2]/input')\
            .send_keys(image_entry)
        # Click on the inset image button
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[1]/div/div/div[3]/button').click()
        # Insert video button
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[5]/div[3]/button[3]').click()
        video_entry = 'https://www.youtube.com/watch?v=Rk_bV0RJRhs&index=20&list=PLJU_WCB1rA2SFwFy3lEvY_NH23ql1-Cgi'
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[4]/div/div/div[2]/div/input')\
            .send_keys(video_entry)
        # Click on the insert video button
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[4]/div/div/div[3]/button').click()
        # Switch back out of the iframe.
        self.selenium.switch_to_default_content()
        # Click on the submit button
        self.selenium.find_element_by_class_name('btn-success').click()
        # Ensure that we are back on the entries page.
        self.selenium.find_element_by_link_text('Add an entry')
        # Ensure that entry exists as the first box on the page.
        box_text = self.selenium.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div[1]/a/div').text
        self.assertTrue(text_entry in box_text)
        self.selenium.find_element_by_xpath("//img[@src='http://images.jfdaily.com/jiefang/wenyu/new/201409/W020140919421426345484.jpg']")
        self.selenium.find_element_by_xpath('//iframe[@src="//www.youtube.com/embed/Rk_bV0RJRhs"]')

    def test_delete_entry(self):
        """Test to ensure that a student can delete an entry"""
        # Click on the first activity box: Walking around the block
        self.selenium.find_element_by_xpath('/html/body/div[1]/div[2]/div/div[1]/div/div[3]/a/div').click()
        self.selenium.find_element_by_link_text('Add an entry').click()
        # The following has 2 matching: Just walking and Adding entry...block
        header_text = self.selenium.find_elements_by_tag_name('h3')[1].text
        self.assertTrue('Adding entry for Walking around the block!' in header_text)
        # Switching to iframe focus
        self.selenium.switch_to_frame(self.selenium.find_element_by_id('id_entry_iframe'))
        # Insert text
        text_entry = 'I think I will bring my cat out next time.'
        self.selenium.find_element_by_class_name('note-editable')\
            .send_keys(text_entry)
        # Insert image button
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[5]/div[3]/button[2]').click()
        image_entry = 'http://images.jfdaily.com/jiefang/wenyu/new/201409/W020140919421426345484.jpg'
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[1]/div/div/div[2]/div[2]/input')\
            .send_keys(image_entry)
        # Click on the inset image button
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[1]/div/div/div[3]/button').click()
        # Insert video button
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[5]/div[3]/button[3]').click()
        video_entry = 'https://www.youtube.com/watch?v=Rk_bV0RJRhs&index=20&list=PLJU_WCB1rA2SFwFy3lEvY_NH23ql1-Cgi'
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[4]/div/div/div[2]/div/input')\
            .send_keys(video_entry)
        # Click on the insert video button
        self.selenium.find_element_by_xpath('/html/body/div[2]/div[2]/div[4]/div/div/div[3]/button').click()
        # Switch back out of the iframe.
        self.selenium.switch_to_default_content()
        # Click on the submit button
        self.selenium.find_element_by_class_name('btn-success').click()
        # Ensure that we are back on the entries page.
        self.selenium.find_element_by_link_text('Add an entry')
        # Ensure that entry exists as the first box on the page.
        box_text = self.selenium.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div[1]/a/div').text
        self.assertTrue(text_entry in box_text)
        self.selenium.find_element_by_xpath("//img[@src='http://images.jfdaily.com/jiefang/wenyu/new/201409/W020140919421426345484.jpg']")
        self.selenium.find_element_by_xpath('//iframe[@src="//www.youtube.com/embed/Rk_bV0RJRhs"]')
        # Click on the entry that was created
        self.selenium.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div[1]/a').click()
        # Click on the delete button
        self.selenium.find_element_by_class_name('btn-danger').click()
        self.selenium.find_element_by_xpath('//*[@id="delete-modal"]/div/div/div[3]/a').click()
        # Ensure that we are back on the entries page.
        self.selenium.find_element_by_link_text('Add an entry')
        # Ensure that the entry created is no longer on the entries page
        main_text = self.selenium.find_element_by_class_name('main').text
        # Check for text
        self.assertFalse(text_entry in main_text)
        # Check for image
        image_entry_xpath = "//img[@src='http://images.jfdaily.com/jiefang/wenyu/new/201409/W020140919421426345484.jpg']"
        self.assertFalse(image_entry_xpath in main_text)
        # Check for video
        video_entry_xpath = '//iframe[@src="//www.youtube.com/embed/Rk_bV0RJRhs"]'
        self.assertFalse(video_entry_xpath in main_text)
Exemplo n.º 33
0
            "//select[@id='stoneTypeSelect']//option[2]").is_selected():
        wd.find_element_by_xpath(
            "//select[@id='stoneTypeSelect']//option[2]").click()
    wd.find_element_by_xpath("//div[@id='tab-stoneType']//a[.='Next']").click()
    wd.find_element_by_css_selector("span.month_text").click()
    wd.find_element_by_xpath(
        "//div[@id='tab-stones-1']/div/ul[2]/li[1]/label/span[2]").click()
    wd.find_element_by_xpath(
        "//div[@id='tab-stones-1']/div/ul[2]/li[1]/label/span[1]").click()
    wd.find_element_by_xpath(
        "//div[@id='tab-stones-1']/div/ul[2]/li[1]/label/input").click()
    wd.find_element_by_xpath(
        "//div[@id='tab-stones-1']/div/ul[2]/li[1]/label/span[1]").click()
    if not wd.find_element_by_xpath(
            "//div[@id='tab-stones-1']/div/ul[2]/li[1]/label/input"
    ).is_selected():
        wd.find_element_by_xpath(
            "//div[@id='tab-stones-1']/div/ul[2]/li[1]/label/input").click()
    wd.find_element_by_link_text("SELECT").click()
    wd.find_element_by_xpath("//div[@id='tab-stones']//a[.='Next']").click()
    wd.find_element_by_id("addToCart").click()
    wd.find_element_by_link_text("CHECKOUT").click()
    if not ("Shopping Bag (1 Item)"
            in wd.find_element_by_tag_name("html").text):
        success = False
        print("verifyTextPresent failed")
finally:
    wd.quit()
    if not success:
        raise Exception("Test failed.")
Exemplo n.º 34
0
class OfferTest(LiveServerTestCase):
    def setUp(self):
        self.name_professor = 'teste'
        self.create_timePeriod_and_course()
        self.create_professor_and_schedule()
        self.browser = WebDriver()
        create_user_and_login(self.browser, self.live_server_url, 'john',
                              'johnpassword', '*****@*****.**')
        self.browser.implicitly_wait(40)

    def tearDown(self):
        cursor = MySQLConnection()
        [offer.delete() for offer in Offer.find()]
        [schedule.delete() for schedule in Schedule.find()]
        cursor.execute('DELETE FROM minitableDayOfTheWeek')
        [timePeriod.delete() for timePeriod in TimePeriod.find()]
        [course.delete() for course in Course.find()]
        [professor.delete() for professor in Professor.find()]
        self.browser.quit()

    def create_timePeriod_and_course(self):
        cursor = MySQLConnection()
        length = cursor.execute(
            'SELECT idLength FROM minitableLength where length="Semestral"')
        if not length:
            cursor.execute(
                'INSERT INTO minitableLength (length) values ("Semestral")')
        self.course = Course('tst9999', 'teste9999', '0000-00-00')
        self.course.store()
        length = cursor.execute(
            'SELECT idLength FROM minitableLength where length="Semestral"')
        self.timePeriod = TimePeriod(1, 2014, 1)
        self.timePeriod.store()

    def create_professor_and_schedule(self):
        cursor = MySQLConnection()
        cursor.execute(
            'INSERT INTO `minitableDayOfTheWeek` (dayOfTheWeek) VALUES ("Domingo"), ("Segunda"), ("Terça"), ("Quarta"), ("Quinta"), ("Sexta"), ("Sabado")'
        )
        self.schedule = Schedule('Domingo', '14:00:00', 'weekly', '12:00:00')
        self.schedule.store()
        self.schedule = Schedule('Segunda', '19:00:00', 'weekly', '16:00:00')
        self.schedule.store()
        self.schedule = Schedule('Quarta', '16:00:00', 'weekly', '14:00:00')
        self.schedule.store()
        self.professor = Professor('Professor Teste')
        self.professor.store()
        self.second_professor = Professor('Professor Teste2')
        self.second_professor.store()

    def login_to_offer_page(self):
        open_page(self.browser, '/interface/', self.live_server_url)
        dropdown_timePeriod = self.browser.find_element_by_id(
            'id_dropDownTimePeriod')
        dropdown_course = self.browser.find_element_by_id('id_dropDownCourse')
        select_timePeriod = Select(dropdown_timePeriod)
        select_timePeriod.select_by_value(str(self.timePeriod.idTimePeriod))
        select_course = Select(dropdown_course)
        select_course.select_by_value(str(self.course.idCourse))
        professor_interface = self.browser.find_element_by_link_text('Offer')
        professor_interface.click()
        self.assertIn('Interface - Offer', self.browser.title)

    def test_create_offer(self):
        self.login_to_offer_page()
        button_create_offer = self.browser.find_element_by_name('criar')
        button_create_offer.click()
        self.assertIn('Interface - Offer Create', self.browser.title)
        dropdown_professor = self.browser.find_element_by_id(
            'id_dropDownProfessor')
        select_professor = Select(dropdown_professor)
        select_professor.select_by_value(str(self.professor.idProfessor))
        input_classNumber = self.browser.find_element_by_id('id_classNumber')
        input_classNumber.send_keys('1')
        dropdown_practical = self.browser.find_element_by_id(
            'id_dropDownTeoricaPratica')
        select_practical = Select(dropdown_practical)
        select_practical.select_by_value('1')
        input_numberOfRegistrations = self.browser.find_element_by_id(
            'id_numberOfRegistrations')
        input_numberOfRegistrations.send_keys('10')
        self.browser.find_element_by_id("id_listSchedules_0").click()
        self.browser.find_element_by_id("id_listSchedules_1").click()
        self.browser.find_element_by_id("id_listSchedules_2").click()
        button_store = self.browser.find_element_by_name('Cadastrar')
        button_store.click()
        self.assertIn('Interface - Offer Detail', self.browser.title)
        id_courseCode = self.browser.find_element_by_id('courseCode')
        self.assertEqual(id_courseCode.text, 'tst9999')
        id_name = self.browser.find_element_by_id('name')
        self.assertEqual(id_name.text, 'teste9999')
        id_professor_name = self.browser.find_element_by_id('professor_name')
        self.assertEqual(id_professor_name.text, 'Professor Teste')
        id_timePeriod = self.browser.find_element_by_id('timePeriod')
        self.assertEqual(id_timePeriod.text, 'Primeiro semestre de 2014')
        id_classNumber = self.browser.find_element_by_id('classNumber')
        self.assertEqual(id_classNumber.text, 'T01')
        id_practical = self.browser.find_element_by_id('practical')
        self.assertEqual(id_practical.text, "TEORICA")
        id_numberOfRegistrations = self.browser.find_element_by_id(
            'numberOfRegistrations')
        self.assertEqual(id_numberOfRegistrations.text, '10')
        id_schedules = self.browser.find_element_by_id('schedules')
        self.assertIn("Domingo 12:00 - 14:00", id_schedules.text)
        self.assertIn("Segunda 16:00 - 19:00", id_schedules.text)
        self.assertIn("Quarta 14:00 - 16:00", id_schedules.text)

    def test_edit_offer(self):
        timePeriod = TimePeriod.find()[0]
        course = Course.find()[0]
        first_professor = Professor.find()[0]
        schedules = Schedule.find()
        offer = Offer(timePeriod, course, 10, 0, first_professor)
        offer.setNumberOfRegistrations(10)
        offer.setSchedules(schedules)
        offer.store()
        open_page(self.browser, '/interface/offer/' + str(offer.idOffer),
                  self.live_server_url)
        self.assertIn('Interface - Offer Detail', self.browser.title)
        button_edit = self.browser.find_element_by_name('editar')
        button_edit.click()
        self.assertIn('Interface - Offer Edit', self.browser.title)
        dropdown_professor = self.browser.find_element_by_id(
            'id_dropDownProfessor')
        select_professor = Select(dropdown_professor)
        select_professor.select_by_value(str(
            self.second_professor.idProfessor))
        input_classNumber = self.browser.find_element_by_id('id_classNumber')
        input_classNumber.send_keys('1')
        dropdown_practical = self.browser.find_element_by_id(
            'id_dropDownTeoricaPratica')
        select_practical = Select(dropdown_practical)
        select_practical.select_by_value('1')
        input_numberOfRegistrations = self.browser.find_element_by_id(
            'id_numberOfRegistrations')
        input_numberOfRegistrations.send_keys('1')
        self.browser.find_element_by_id("id_listSchedules_1").click()
        self.browser.find_element_by_id("id_listSchedules_2").click()
        button_apply = self.browser.find_element_by_name('Aplicar')
        button_apply.click()
        self.assertIn('Interface - Offer Detail', self.browser.title)
        id_courseCode = self.browser.find_element_by_id('courseCode')
        self.assertEqual(id_courseCode.text, 'tst9999')
        id_name = self.browser.find_element_by_id('name')
        self.assertEqual(id_name.text, 'teste9999')
        id_professor_name = self.browser.find_element_by_id('professor_name')
        self.assertEqual(id_professor_name.text, 'Professor Teste2')
        id_timePeriod = self.browser.find_element_by_id('timePeriod')
        self.assertEqual(id_timePeriod.text, 'Primeiro semestre de 2014')
        id_classNumber = self.browser.find_element_by_id('classNumber')
        self.assertEqual(id_classNumber.text, 'T101')
        id_practical = self.browser.find_element_by_id('practical')
        self.assertEqual(id_practical.text, "PRATICA")
        id_numberOfRegistrations = self.browser.find_element_by_id(
            'numberOfRegistrations')
        self.assertEqual(id_numberOfRegistrations.text, '101')
        id_schedules = self.browser.find_element_by_id('schedules')
        self.assertIn("Domingo 12:00 - 14:00", id_schedules.text)
        self.assertNotIn("Segunda 16:00 - 19:00", id_schedules.text)
        self.assertNotIn("Quarta 14:00 - 16:00", id_schedules.text)

    def test_delete_offer(self):
        timePeriod = TimePeriod.find()[0]
        course = Course.find()[0]
        first_professor = Professor.find()[0]
        schedules = Schedule.find()
        offer = Offer(timePeriod, course, 10, 0, first_professor)
        offer.setNumberOfRegistrations(10)
        offer.setSchedules(schedules)
        offer.store()
        open_page(self.browser, '/interface/offer/' + str(offer.idOffer),
                  self.live_server_url)
        self.assertIn('Interface - Offer Detail', self.browser.title)
        button_delete = self.browser.find_element_by_name('deletar')
        button_delete.click()
        alert = self.browser.switch_to.alert
        alert.accept()
        self.assertIn('Interface', self.browser.title)
        open_page(self.browser, '/interface/offer/' + str(offer.idOffer),
                  self.live_server_url)
        self.assertNotIn('Interface - Offer Detail', self.browser.title)
def syn_test_script():

    try:
        success = True
        driver = WebDriver()
        driver.implicitly_wait(30)
        # Disabled page sizing and instead used action chains to move mouse around
        #driver.set_window_size(1920, 1080)

        # Use Action chains to navigate page when there is an issue with the selection menus
        # If the menu item does not appear to select, it means there was a page movement that happened
        # out of sync with the action.

        #------Insert Script between these lines-----#
        driver.get(
            "http://www.jared.com/en/jaredstore/searchterm/731434000/true/731434000"
        )

        # Search HTML for text to verify page
        log_output("Step - Verify Search worked")
        if not ("items" in driver.find_element_by_tag_name("html").text):
            success = False
            print("verifyTextPresent failed")

        log_output("Step - Select item via partial link text")
        driver.find_element_by_partial_link_text(
            "Mother's Bracelet Round Birthstones Design in Silver").click()

        log_output("Start customizing Jewelery")

        log_output("    Select Number of stones (1)")
        if not driver.find_element_by_xpath(
                "//select[@id='configSelect']//option[2]").is_selected():
            driver.find_element_by_xpath(
                "//select[@id='configSelect']//option[2]").click()
        driver.find_element_by_id("btnStartCustomizing").click()

        log_output("    Select metal type")
        if not driver.find_element_by_xpath(
                "//select[@id='metalTypeSelect']//option[2]").is_selected():
            driver.find_element_by_xpath(
                "//select[@id='metalTypeSelect']//option[2]").click()
        driver.find_element_by_id("next-step").click()

        log_output("    Select stone type")
        if not driver.find_element_by_xpath(
                "//select[@id='stoneTypeSelect']//option[2]").is_selected():
            driver.find_element_by_xpath(
                "//select[@id='stoneTypeSelect']//option[2]").click()
        driver.find_element_by_xpath(
            "//div[@id='tab-stoneType']//a[.='Next']").click()

        log_output("    Select birthstone")
        driver.find_element_by_css_selector("span.month_text").click()
        driver.find_element_by_xpath(
            "//div[@id='tab-stones-1']/div/ul[2]/li[1]/label/span[2]").click()
        driver.find_element_by_xpath(
            "//div[@id='tab-stones-1']/div/ul[2]/li[1]/label/span[1]").click()
        driver.find_element_by_xpath(
            "//div[@id='tab-stones-1']/div/ul[2]/li[1]/label/input").click()
        driver.find_element_by_xpath(
            "//div[@id='tab-stones-1']/div/ul[2]/li[1]/label/span[1]").click()
        if not driver.find_element_by_xpath(
                "//div[@id='tab-stones-1']/div/ul[2]/li[1]/label/input"
        ).is_selected():
            driver.find_element_by_xpath(
                "//div[@id='tab-stones-1']/div/ul[2]/li[1]/label/input").click(
                )
        driver.find_element_by_link_text("SELECT").click()
        driver.find_element_by_xpath(
            "//div[@id='tab-stones']//a[.='Next']").click()
        driver.find_element_by_id("addToCart").click()
        driver.find_element_by_link_text("CHECKOUT").click()
        if not ("Shopping Bag (1 Item)"
                in driver.find_element_by_tag_name("html").text):
            success = False
            print("verifyTextPresent failed")

        #------Insert Script between these lines-----#

    finally:
        driver.quit()
        if not success:
            raise Exception("Test failed.")
Exemplo n.º 36
0
class FlightSeleniumTestCase(StaticLiveServerTestCase):
    fixtures = ['flights_tests.json']

    def setUp(self):
        user = User.objects.create_user(
            username='******',
            email='*****@*****.**',
            password='******',
        )
        user.first_name = 'Bruce'
        user.last_name = 'Wayne'
        user.save()
        flight = Flight(plane=Plane.objects.get(pk='Batman'),
                        start_date=datetime(2020,
                                            1,
                                            1,
                                            1,
                                            0,
                                            0,
                                            tzinfo=pytz.UTC),
                        end_date=datetime(2020, 1, 1, 6, 0, 0,
                                          tzinfo=pytz.UTC),
                        src_airport=Airport.objects.get(pk='WAW'),
                        dest_airport=Airport.objects.get(pk='TXL'))
        flight.save()
        flight = Flight(plane=Plane.objects.get(pk='Superman'),
                        start_date=datetime(2020,
                                            1,
                                            1,
                                            1,
                                            30,
                                            0,
                                            tzinfo=pytz.UTC),
                        end_date=datetime(2020,
                                          1,
                                          1,
                                          6,
                                          30,
                                          0,
                                          tzinfo=pytz.UTC),
                        src_airport=Airport.objects.get(pk='TXL'),
                        dest_airport=Airport.objects.get(pk='WAW'))
        flight.save()

        self.selenium = WebDriver()
        super(FlightSeleniumTestCase, self).setUp()

    def tearDown(self):
        self.selenium.quit()
        super(FlightSeleniumTestCase, self).tearDown()

    def test_add_passenger(self):
        self.selenium.get(self.live_server_url)

        # login first
        self.selenium.find_element_by_name('username').send_keys('user')
        self.selenium.find_element_by_name('password').send_keys('pass')
        self.selenium.find_element_by_css_selector(
            'input[type="submit"]').click()
        alert = self.selenium.find_element_by_class_name('alert')
        self.assertIn('alert-success', alert.get_attribute('class'))

        # move to flights menu and select first one
        self.selenium.find_element_by_link_text('Flights').click()
        self.selenium.find_element_by_link_text('1').click()

        # click 'Buy ticket' button and check if user shows up on list
        self.selenium.find_element_by_css_selector(
            'input[value="Buy ticket"]').click()
        self.selenium.find_element_by_xpath(
            '//*[@id="headingOne"]/button').click()
        name_td = self.selenium.find_element_by_xpath(
            '//*[@id="collapseOne"]/div/table/tbody/tr/td[2]')
        self.assertEquals('Bruce Wayne', name_td.text)

    def test_crew_add(self):
        crew = Crew(captain_firstname='Bruce', captain_lastname='Wayne')
        crew.save()
        cm = CrewMember(firstname='Clark', lastname='Kent')
        cm.save()
        crew.members.add(cm)
        crew.save()
        action_chains = ActionChains(self.selenium)
        self.selenium.get(self.live_server_url)

        # login first
        self.selenium.find_element_by_link_text('Crews').click()
        self.selenium.find_element_by_name('username').send_keys('user')
        self.selenium.find_element_by_name('password').send_keys('pass')
        self.selenium.find_element_by_xpath(
            '//*[@id="login-form"]/input[3]').click()
        WebDriverWait(
            self.selenium,
            3).until(lambda driver: driver.find_element_by_class_name('alert'))
        alert = self.selenium.find_element_by_class_name('alert')
        self.assertIn('alert-success', alert.get_attribute('class'))

        # setup date of flights
        self.selenium.find_element_by_id('choose-date').send_keys('2020-01-01')
        WebDriverWait(self.selenium,
                      3).until(lambda driver: driver.find_element_by_xpath(
                          '//*[@id="flights"]/tr[1]'))

        # double click on first flight
        row = self.selenium.find_element_by_xpath('//*[@id="flights"]/tr[1]')
        action_chains.double_click(row).perform()

        # choose first crew
        WebDriverWait(self.selenium,
                      3).until(lambda driver: driver.find_element_by_xpath(
                          '//*[@id="select-crew"]/option[2]'))
        self.selenium.find_element_by_xpath(
            '//*[@id="select-crew"]/option[2]').click()

        # send 'Change crew' and wait for change query to end
        self.selenium.find_element_by_xpath(
            '//*[@id="crew-form"]/div[7]/input').click()
        WebDriverWait(
            self.selenium,
            3).until(lambda driver: driver.find_element_by_class_name('alert'))
        alert = self.selenium.find_element_by_class_name('alert')
        self.assertIn('alert-success', alert.get_attribute('class'))

        # refresh page and check if crew changed
        self.selenium.refresh()
        action_chains = ActionChains(self.selenium)
        self.selenium.find_element_by_id('choose-date').send_keys('2020-01-01')
        WebDriverWait(self.selenium,
                      3).until(lambda driver: driver.find_element_by_xpath(
                          '//*[@id="flights"]/tr[1]'))
        new_crew = self.selenium.find_element_by_xpath(
            '//*[@id="flights"]/tr[1]/td[6]/span[@class="captain"]')
        self.assertEquals('Bruce Wayne', new_crew.text)

        # double click on second flight
        row2 = self.selenium.find_element_by_xpath('//*[@id="flights"]/tr[2]')
        action_chains.double_click(row2).perform()

        # choose first crew
        WebDriverWait(self.selenium,
                      3).until(lambda driver: driver.find_element_by_xpath(
                          '//*[@id="select-crew"]/option[2]'))
        self.selenium.find_element_by_xpath(
            '//*[@id="select-crew"]/option[2]').click()

        # send 'Change crew' and wait for change query to end
        self.selenium.find_element_by_xpath(
            '//*[@id="crew-form"]/div[7]/input').click()
        WebDriverWait(
            self.selenium,
            3).until(lambda driver: driver.find_element_by_class_name('alert'))
        alert = self.selenium.find_element_by_class_name('alert')
        self.assertIn('alert-danger', alert.get_attribute('class'))

        # check if crews didn't change
        self.selenium.refresh()
        self.selenium.find_element_by_id('choose-date').send_keys('2020-01-01')
        WebDriverWait(self.selenium,
                      3).until(lambda driver: driver.find_element_by_xpath(
                          '//*[@id="flights"]/tr[1]'))
        crew1 = self.selenium.find_element_by_xpath(
            '//*[@id="flights"]/tr[1]/td[6]/span[@class="captain"]')
        crew2 = self.selenium.find_element_by_xpath(
            '//*[@id="flights"]/tr[2]/td[6]/span[@class="captain"]')
        self.assertEquals('Bruce Wayne', crew1.text)
        self.assertEquals('None', crew2.text)
Exemplo n.º 37
0
Arquivo: tests.py Projeto: gladuo/niji
class RegisteredUserTest(LiveServerTestCase):
    """
    Test as a registered user
    """

    def setUp(self):
        self.browser = WebDriver()
        self.browser.implicitly_wait(3)
        self.n1 = Node.objects.create(
            title='TestNodeOne',
            description='The first test node'
        )
        self.u1 = User.objects.create_user(
            username='******', email='*****@*****.**', password='******'
        )
        self.u2 = User.objects.create_user(
            username='******', email='*****@*****.**', password='******'
        )

        # Create 198 topics
        for i in range(1, 100):
            setattr(
                self,
                't%s' % i,
                Topic.objects.create(
                    title='Test Topic %s' % i,
                    user=self.u1,
                    content_raw='This is test topic __%s__' % i,
                    node=self.n1
                )
            )

        for i in range(100, 199):
            setattr(
                self,
                't%s' % i,
                Topic.objects.create(
                    title='Test Topic %s' % i,
                    user=self.u2,
                    content_raw='This is test topic __%s__' % i,
                    node=self.n1
                )
            )

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

    def test_edit_own_topic(self):
        self.browser.get(self.live_server_url+reverse('niji:index'))
        login(self.browser, "test1", "111")
        self.assertIn("Log out", self.browser.page_source)
        own_topic = getattr(self, "t%s" % (random.choice(range(1, 100))))
        self.browser.get(self.live_server_url+reverse("niji:topic", kwargs={"pk": own_topic.id}))
        self.browser.find_element_by_link_text("Edit").click()
        content_raw = self.browser.find_element_by_name("content_raw")
        content_raw.clear()
        content_raw.send_keys("This topic is edited")
        self.browser.find_element_by_name("submit").click()
        self.assertIn("This topic is edited", self.browser.page_source)

    def test_edit_others_topic(self):
        self.browser.get(self.live_server_url+reverse('niji:index'))
        login(self.browser, "test1", "111")
        self.assertIn("Log out", self.browser.page_source)
        others_topic = getattr(self, "t%s" % (random.choice(range(100, 199))))
        self.browser.get(self.live_server_url+reverse("niji:topic", kwargs={"pk": others_topic.id}))
        self.assertNotIn(
            "<span class=\"label label-success\">Edit</span>",
            self.browser.page_source
        )
        self.browser.get(
            self.live_server_url+reverse("niji:edit_topic", kwargs={"pk": others_topic.id})
        )
        self.assertIn("You are not allowed to edit other's topic", self.browser.page_source)

    def test_reply_topic(self):
        self.browser.get(self.live_server_url+reverse('niji:index'))
        login(self.browser, "test1", "111")
        self.assertIn("Log out", self.browser.page_source)
        topic = getattr(self, "t%s" % (random.choice(range(1, 199))))
        self.browser.get(self.live_server_url+reverse("niji:topic", kwargs={"pk": topic.id}))
        content_raw = self.browser.find_element_by_name("content_raw")
        content_raw.clear()
        content_raw.send_keys("This is a reply")
        self.browser.find_element_by_name("submit").click()
        self.assertIn("This is a reply", self.browser.page_source)

    def test_create_topic(self):
        self.browser.get(self.live_server_url+reverse('niji:index'))
        login(self.browser, "test1", "111")
        self.assertIn("Log out", self.browser.page_source)
        self.browser.get(self.live_server_url+reverse("niji:create_topic"))
        node = self.browser.find_element_by_name("node")
        node = Select(node)
        title = self.browser.find_element_by_name("title")
        content_raw = self.browser.find_element_by_name("content_raw")
        node.select_by_visible_text(self.n1.title)
        title.send_keys("test title")
        content_raw.send_keys("this is content")
        self.browser.find_element_by_name("submit").click()
        self.assertIn("this is content", self.browser.page_source)

    def test_create_appendix(self):
        self.browser.get(self.live_server_url+reverse('niji:index'))
        login(self.browser, "test1", "111")
        self.assertIn("Log out", self.browser.page_source)
        own_topic = getattr(self, "t%s" % (random.choice(range(1, 100))))
        self.browser.get(self.live_server_url+reverse("niji:topic", kwargs={"pk": own_topic.id}))
        self.browser.find_element_by_link_text("Append").click()
        content_raw = self.browser.find_element_by_name("content_raw")
        content_raw.clear()
        content_raw.send_keys("This is an appendix")
        self.browser.find_element_by_name("submit").click()
        self.assertIn("This is an appendix", self.browser.page_source)
def syn_test_script():

    try:
        success = True
        driver = WebDriver()
        driver.implicitly_wait(30)
        # Disabled page sizing and instead used action chains to move mouse around
        #driver.set_window_size(1920, 1080)

        # Use Action chains to navigate page when there is an issue with the selection menus
        # If the menu item does not appear to select, it means there was a page movement that happened
        # out of sync with the action.

        log_output(
            "Starting @ http://www.kay.com/en/kaystore/searchterm/731434000/true/731434000"
        )
        driver.get(
            "http://www.kay.com/en/kaystore/searchterm/731434000/true/731434000"
        )

        log_output("Click on first item to customize a ring - don't use /div")
        driver.find_element_by_partial_link_text(
            "Family/Mother's Ring Round Birthstones Design in Silver or Gold"
        ).click()

        log_output("Start customizing ring")
        driver.find_element_by_xpath(
            "//div[@class='m-vcb-content-html-modifier']//button[.='Start Customizing']"
        ).click()
        if not driver.find_element_by_xpath(
                "//select[@id='configSelect']//option[2]").is_selected():
            driver.find_element_by_xpath(
                "//select[@id='configSelect']//option[2]").click()
        driver.find_element_by_id("btnStartCustomizing").click()

        log_output("Step - Select Metal Type")
        if not driver.find_element_by_xpath(
                "//select[@id='metalTypeSelect']//option[2]").is_selected():
            driver.find_element_by_xpath(
                "//select[@id='metalTypeSelect']//option[2]").click()
        driver.find_element_by_id("next-step").click()

        log_output("Step - Stelect Stone Type")
        ActionChains(driver).move_to_element(
            driver.find_element_by_xpath(
                "//select[@id='stoneTypeSelect']")).perform()
        if not driver.find_element_by_xpath(
                "//select[@id='stoneTypeSelect']//option[2]").is_selected():
            driver.find_element_by_xpath(
                "//select[@id='stoneTypeSelect']//option[2]").click()

        log_output("Step - Click Next")
        ActionChains(driver).move_to_element(
            driver.find_element_by_xpath(
                "//div[@id='tab-stoneType']//a[.='Next']")).perform()
        driver.find_element_by_xpath("//div[@id='tab-stoneType']//a[.='Next']")
        driver.find_element_by_xpath(
            "//div[@id='tab-stoneType']//a[.='Next']").click()

        log_output("Step - Select Birth Stone")
        driver.find_element_by_css_selector("span.month_text").click()
        driver.find_element_by_xpath(
            "//div[@id='tab-stones-1']/div/ul[2]/li[1]/label/span[2]").click()
        driver.find_element_by_xpath(
            "//div[@id='tab-stones-1']/div/ul[2]/li[1]/label/span[1]").click()
        driver.find_element_by_xpath(
            "//div[@id='tab-stones-1']/div/ul[2]/li[1]/label/input").click()
        driver.find_element_by_xpath(
            "//div[@id='tab-stones-1']/div/ul[2]/li[1]/label/span[1]").click()
        if not driver.find_element_by_xpath(
                "//div[@id='tab-stones-1']/div/ul[2]/li[1]/label/input"
        ).is_selected():
            driver.find_element_by_xpath(
                "//div[@id='tab-stones-1']/div/ul[2]/li[1]/label/input").click(
                )
        driver.find_element_by_link_text("SELECT").click()
        driver.find_element_by_xpath(
            "//a[@id='tab-index-2']//span[.='Select a Stone']").click()
        driver.find_element_by_xpath(
            "//div[@id='tab-stones-2']/div/ul[2]/li[2]/label/span[2]").click()
        driver.find_element_by_xpath(
            "//div[@id='tab-stones-2']/div/ul[2]/li[2]/label/span[1]").click()
        driver.find_element_by_xpath(
            "//div[@id='tab-stones-2']/div/ul[2]/li[2]/label/input").click()
        driver.find_element_by_xpath(
            "//div[@id='tab-stones-2']/div/ul[2]/li[2]/label/span[1]").click()
        if not driver.find_element_by_xpath(
                "//div[@id='tab-stones-2']/div/ul[2]/li[2]/label/input"
        ).is_selected():
            driver.find_element_by_xpath(
                "//div[@id='tab-stones-2']/div/ul[2]/li[2]/label/input").click(
                )
        driver.find_element_by_link_text("SELECT").click()
        driver.find_element_by_xpath(
            "//div[@id='tab-stones']//a[.='Next']").click()

        log_output("Step - Select Ring Size")
        if not driver.find_element_by_xpath(
                "//select[@id='sizeSelect']//option[7]").is_selected():
            driver.find_element_by_xpath(
                "//select[@id='sizeSelect']//option[7]").click()
        driver.find_element_by_xpath(
            "//div[@id='tab-sizes']//a[.='Next']").click()

        log_output("Add to Cart and Checkout")
        driver.find_element_by_id("addToCart").click()
        driver.find_element_by_link_text("CHECKOUT").click()

    finally:
        driver.quit()
        if not success:
            raise Exception("Test failed.")
Exemplo n.º 39
0
Arquivo: tests.py Projeto: astucse/SAS
class VisitorTest(LiveServerTestCase):
    """
    Test as a visitor (unregistered user)
    """
    def setUp(self):
        self.browser = WebDriver()
        self.browser.implicitly_wait(3)
        self.n1 = Node.objects.create(title='TestNodeOne',
                                      description='The first test node')
        self.u1 = User.objects.create_user(username='******',
                                           email='*****@*****.**',
                                           password='******')
        self.u2 = User.objects.create_user(username='******',
                                           email='*****@*****.**',
                                           password='******')

        # Create 99 topics
        for i in range(1, 100):
            setattr(
                self, 't%s' % i,
                Topic.objects.create(title='Test Topic %s' % i,
                                     user=self.u1,
                                     content_raw='This is test topic __%s__' %
                                     i,
                                     node=self.n1))

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

    def test_index(self):
        self.browser.get(self.live_server_url + reverse('index'))
        self.assertIn('niji', self.browser.page_source.lower())

    def test_topic_page_content(self):
        self.browser.get(self.live_server_url +
                         reverse('topic', kwargs={'pk': self.t88.pk}))
        self.assertIn('This is test topic <strong>88</strong>',
                      self.browser.page_source)

    def test_hidden_post(self):
        hidden_post = Post.objects.create(topic=self.t1,
                                          content_raw="i'm a reply 12138",
                                          user=self.u1)
        self.browser.get(self.live_server_url +
                         reverse('topic', kwargs={'pk': self.t1.pk}))
        self.assertIn("i'm a reply 12138", self.browser.page_source)
        hidden_post.hidden = True
        hidden_post.save()
        self.browser.get(self.browser.current_url)
        self.assertNotIn("i'm a reply 12138", self.browser.page_source)

    def test_node_page(self):
        self.browser.get(self.live_server_url +
                         reverse('node', kwargs={'pk': self.n1.pk}))
        topics = self.browser.find_elements_by_css_selector(
            'ul.topic-list > li')
        self.assertEqual(len(topics), 30)

    def test_user_login(self):
        self.browser.get(self.live_server_url + reverse('index'))
        self.assertNotIn("Log out", self.browser.page_source)
        login(self.browser, "test1", "111")
        self.assertEqual(self.browser.current_url,
                         self.live_server_url + reverse("index"))
        self.assertIn("Log out", self.browser.page_source)

    def test_usr_reg(self):
        self.browser.get(self.live_server_url + reverse('index'))
        self.browser.find_element_by_link_text("Reg").click()
        self.assertEqual(self.browser.current_url,
                         self.live_server_url + reverse("reg"))
        username = self.browser.find_element_by_name('username')
        email = self.browser.find_element_by_name('email')
        password1 = self.browser.find_element_by_name('password1')
        password2 = self.browser.find_element_by_name('password2')
        username.send_keys("test3")
        password1.send_keys("333")
        password2.send_keys("333")
        email.send_keys("*****@*****.**")
        password1.send_keys(Keys.RETURN)
        self.assertEqual(self.browser.current_url,
                         self.live_server_url + reverse("index"))
        self.assertIn("Log out", self.browser.page_source)
        self.assertIn("test3", self.browser.page_source)

    def test_user_topic(self):
        self.browser.get(self.live_server_url +
                         reverse("user_topics", kwargs={"pk": self.u1.id}))
        self.assertIn("UID:", self.browser.page_source)

    def test_user_info(self):
        self.browser.get(self.live_server_url +
                         reverse("user_info", kwargs={"pk": self.u1.id}))
        self.assertIn("Topics created by %s" % self.u1.username,
                      self.browser.page_source)

    def test_search(self):
        self.browser.get(self.live_server_url +
                         reverse("search", kwargs={"keyword": "test"}))
        self.assertIn("Search: test", self.browser.page_source)

    def test_pagination(self):
        self.browser.get(self.live_server_url +
                         reverse("index", kwargs={"page": 2}))
        self.assertIn("«", self.browser.page_source)
        prev = self.browser.find_element_by_link_text("«")
        prev.click()
        self.assertNotIn("«", self.browser.page_source)
        self.assertIn("»", self.browser.page_source)
        nxt = self.browser.find_element_by_link_text("»")
        nxt.click()
        self.assertEqual(
            self.browser.current_url,
            self.live_server_url + reverse("index", kwargs={"page": 2}))
Exemplo n.º 40
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("https://investor.vanguard.com/corporate-portal/")
    wd.find_element_by_css_selector("span.linkStyle").click()
    wd.find_element_by_link_text("Open an IRA in minutes").click()
finally:
    wd.quit()
    if not success:
        raise Exception("Test failed.")
Exemplo n.º 41
0
class OfferTest (LiveServerTestCase):
       
    def setUp(self):
        self.name_professor = 'teste'
        self.create_timePeriod_and_course()
        self.create_professor_and_schedule()
        self.browser = WebDriver()
        create_user_and_login(self.browser, self.live_server_url,'john','johnpassword','*****@*****.**')
        self.browser.implicitly_wait(40)
        
    def tearDown(self):
        cursor = MySQLConnection()
        [offer.delete() for offer in Offer.find()]
        [schedule.delete() for schedule in Schedule.find()]
        cursor.execute('DELETE FROM minitableDayOfTheWeek')
        [timePeriod.delete() for timePeriod in TimePeriod.find()]
        [course.delete() for course in Course.find()]
        [professor.delete() for professor in Professor.find()]
        self.browser.quit()
        
    def create_timePeriod_and_course(self):
        cursor = MySQLConnection()
        length = cursor.execute('SELECT idLength FROM minitableLength where length="Semestral"')
        if not length:
            cursor.execute('INSERT INTO minitableLength (length) values ("Semestral")')
        self.course = Course('tst9999', 'teste9999', '0000-00-00')
        self.course.store()
        length = cursor.execute('SELECT idLength FROM minitableLength where length="Semestral"')
        self.timePeriod = TimePeriod(1, 2014, 1)
        self.timePeriod.store()
        
    def create_professor_and_schedule(self):
        cursor = MySQLConnection()
        cursor.execute('INSERT INTO `minitableDayOfTheWeek` (dayOfTheWeek) VALUES ("Domingo"), ("Segunda"), ("Terça"), ("Quarta"), ("Quinta"), ("Sexta"), ("Sabado")')
        self.schedule = Schedule('Domingo', '14:00:00', 'weekly', '12:00:00')
        self.schedule.store()
        self.schedule = Schedule('Segunda', '19:00:00', 'weekly', '16:00:00')
        self.schedule.store()
        self.schedule = Schedule('Quarta', '16:00:00', 'weekly', '14:00:00')
        self.schedule.store()
        self.professor = Professor('Professor Teste')
        self.professor.store()
        self.second_professor = Professor('Professor Teste2')
        self.second_professor.store()
                
    def login_to_offer_page(self):
        open_page(self.browser, '/interface/', self.live_server_url)
        dropdown_timePeriod = self.browser.find_element_by_id('id_dropDownTimePeriod')
        dropdown_course = self.browser.find_element_by_id('id_dropDownCourse')
        select_timePeriod = Select(dropdown_timePeriod)
        select_timePeriod.select_by_value(str(self.timePeriod.idTimePeriod))
        select_course = Select(dropdown_course)
        select_course.select_by_value(str(self.course.idCourse))
        professor_interface = self.browser.find_element_by_link_text('Offer')
        professor_interface.click()
        self.assertIn('Interface - Offer', self.browser.title)
        
    def test_create_offer(self):
        self.login_to_offer_page()
        button_create_offer = self.browser.find_element_by_name('criar')
        button_create_offer.click()
        self.assertIn('Interface - Offer Create', self.browser.title)
        dropdown_professor = self.browser.find_element_by_id('id_dropDownProfessor')
        select_professor = Select(dropdown_professor)
        select_professor.select_by_value(str(self.professor.idProfessor))
        input_classNumber = self.browser.find_element_by_id('id_classNumber')
        input_classNumber.send_keys('1')
        dropdown_practical = self.browser.find_element_by_id('id_dropDownTeoricaPratica')
        select_practical = Select(dropdown_practical)
        select_practical.select_by_value('1')
        input_numberOfRegistrations = self.browser.find_element_by_id('id_numberOfRegistrations')
        input_numberOfRegistrations.send_keys('10')
        self.browser.find_element_by_id("id_listSchedules_0").click()
        self.browser.find_element_by_id("id_listSchedules_1").click()
        self.browser.find_element_by_id("id_listSchedules_2").click()
        button_store = self.browser.find_element_by_name('Cadastrar')
        button_store.click()
        self.assertIn('Interface - Offer Detail', self.browser.title)
        id_courseCode = self.browser.find_element_by_id('courseCode')
        self.assertEqual(id_courseCode.text, 'tst9999')
        id_name = self.browser.find_element_by_id('name')
        self.assertEqual(id_name.text, 'teste9999')
        id_professor_name = self.browser.find_element_by_id('professor_name')
        self.assertEqual(id_professor_name.text, 'Professor Teste')
        id_timePeriod = self.browser.find_element_by_id('timePeriod')
        self.assertEqual(id_timePeriod.text, 'Primeiro semestre de 2014')
        id_classNumber = self.browser.find_element_by_id('classNumber')
        self.assertEqual(id_classNumber.text, 'T01')
        id_practical = self.browser.find_element_by_id('practical')
        self.assertEqual(id_practical.text, "TEORICA")
        id_numberOfRegistrations = self.browser.find_element_by_id('numberOfRegistrations')
        self.assertEqual(id_numberOfRegistrations.text, '10')
        id_schedules = self.browser.find_element_by_id('schedules')
        self.assertIn("Domingo 12:00 - 14:00", id_schedules.text)
        self.assertIn("Segunda 16:00 - 19:00", id_schedules.text)
        self.assertIn("Quarta 14:00 - 16:00", id_schedules.text)
        
    def test_edit_offer(self):
        timePeriod = TimePeriod.find()[0]
        course = Course.find()[0]
        first_professor = Professor.find()[0]
        schedules = Schedule.find()
        offer = Offer(timePeriod, course, 10, 0, first_professor)
        offer.setNumberOfRegistrations(10)
        offer.setSchedules(schedules)
        offer.store()
        open_page(self.browser, '/interface/offer/' + str(offer.idOffer), self.live_server_url)
        self.assertIn('Interface - Offer Detail', self.browser.title)
        button_edit = self.browser.find_element_by_name('editar')
        button_edit.click()
        self.assertIn('Interface - Offer Edit', self.browser.title)
        dropdown_professor = self.browser.find_element_by_id('id_dropDownProfessor')
        select_professor = Select(dropdown_professor)
        select_professor.select_by_value(str(self.second_professor.idProfessor))
        input_classNumber = self.browser.find_element_by_id('id_classNumber')
        input_classNumber.send_keys('1')
        dropdown_practical = self.browser.find_element_by_id('id_dropDownTeoricaPratica')
        select_practical = Select(dropdown_practical)
        select_practical.select_by_value('1')
        input_numberOfRegistrations = self.browser.find_element_by_id('id_numberOfRegistrations')
        input_numberOfRegistrations.send_keys('1')
        self.browser.find_element_by_id("id_listSchedules_1").click()
        self.browser.find_element_by_id("id_listSchedules_2").click()
        button_apply = self.browser.find_element_by_name('Aplicar')
        button_apply.click()
        self.assertIn('Interface - Offer Detail', self.browser.title)
        id_courseCode = self.browser.find_element_by_id('courseCode')
        self.assertEqual(id_courseCode.text, 'tst9999')
        id_name = self.browser.find_element_by_id('name')
        self.assertEqual(id_name.text, 'teste9999')
        id_professor_name = self.browser.find_element_by_id('professor_name')
        self.assertEqual(id_professor_name.text, 'Professor Teste2')
        id_timePeriod = self.browser.find_element_by_id('timePeriod')
        self.assertEqual(id_timePeriod.text, 'Primeiro semestre de 2014')
        id_classNumber = self.browser.find_element_by_id('classNumber')
        self.assertEqual(id_classNumber.text, 'T101')
        id_practical = self.browser.find_element_by_id('practical')
        self.assertEqual(id_practical.text, "PRATICA")
        id_numberOfRegistrations = self.browser.find_element_by_id('numberOfRegistrations')
        self.assertEqual(id_numberOfRegistrations.text, '101')
        id_schedules = self.browser.find_element_by_id('schedules')
        self.assertIn("Domingo 12:00 - 14:00", id_schedules.text)
        self.assertNotIn("Segunda 16:00 - 19:00", id_schedules.text)
        self.assertNotIn("Quarta 14:00 - 16:00", id_schedules.text)
        
    def test_delete_offer(self):
        timePeriod = TimePeriod.find()[0]
        course = Course.find()[0]
        first_professor = Professor.find()[0]
        schedules = Schedule.find()
        offer = Offer(timePeriod, course, 10, 0, first_professor)
        offer.setNumberOfRegistrations(10)
        offer.setSchedules(schedules)
        offer.store()
        open_page(self.browser, '/interface/offer/' + str(offer.idOffer), self.live_server_url)
        self.assertIn('Interface - Offer Detail', self.browser.title)
        button_delete = self.browser.find_element_by_name('deletar')
        button_delete.click()
        alert = self.browser.switch_to.alert
        alert.accept()
        self.assertIn('Interface', self.browser.title)
        open_page(self.browser, '/interface/offer/' + str(offer.idOffer), self.live_server_url)
        self.assertNotIn('Interface - Offer Detail', self.browser.title)
        
Exemplo n.º 42
0
    try:
        wd.switch_to_alert().text
        return True
    except:
        return False

try:
    wd.get("http://localhost/addressbook/")
    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_name("user").click()
    wd.find_element_by_name("user").clear()
    wd.find_element_by_name("user").send_keys("admin")
    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("new froup")
    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("new grope")
    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("new grpi")
    wd.find_element_by_name("submit").click()
    wd.find_element_by_link_text("group page").click()
    wd.find_element_by_link_text("Logout").click()
    wd.find_element_by_name("user").click()
    wd.find_element_by_name("user").send_keys("\\undefined")
Exemplo n.º 43
0
class ActivitySeleleniumTests(StaticLiveServerTestCase):
    """Selenium tests for the activity page"""

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        if not settings.DEBUG:
            settings.DEBUG = True
        if not settings.TESTING:
            settings.TESTING = True

    def setUp(self):
        """Handles login and things"""
        call_command('flush', interactive=False, verbosity=0)  # Clears db
        call_command('loaddata', 'groups', commit=False, verbosity=0)
        call_command('loaddata', 'school', commit=False, verbosity=0)
        call_command('loaddata', 'permissions', commit=False, verbosity=0)
        call_command('loaddata', 'auth_users', commit=False, verbosity=0)
        call_command('loaddata', 'student', commit=False, verbosity=0)
        call_command('loaddata', 'advisor', commit=False, verbosity=0)
        call_command('loaddata', 'coordinator', commit=False, verbosity=0)
        call_command('loaddata', 'activityoptions', commit=False, verbosity=0)
        call_command('loaddata', 'learningobjectiveoptions', commit=False, verbosity=0)
        call_command('loaddata', 'sample_entries', commit=False, verbosity=0)
        self.selenium = WebDriver()
        self.selenium.set_window_size(1024, 800)
        self.selenium.get('{0}/{1}'.format(self.live_server_url, ''))
        self.selenium.find_element_by_xpath('//*[@id="djHideToolBarButton"]').click()
        self.selenium.implicitly_wait(10)
        self.selenium.find_element_by_link_text('Login').click()
        # Click on the student button in the gateway
        self.selenium.find_element_by_xpath('/html/body/center/md-content/div/div/div[1]/a').click()
        self.selenium\
            .find_element_by_xpath("//img[@src='/static/journal/activities/img"
                                   "/journal_sign.png']")
        super()

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

    def test_activity_form_back(self):
        """make sure the back button works"""
        self.selenium.find_element_by_xpath("/html/body/div[1]/div[2]/div/div[1]/div/div[2]/div/a").click()
        self.selenium.find_element_by_name('activity_name').send_keys('Walking the cat')
        self.selenium.find_element_by_name('activity_description').send_keys('Walking the cat around the neighborhood')
        self.selenium.find_element_by_xpath('/html/body/div[1]/div[2]/div[1]/form/div[2]/div[2]/input').send_keys('02/07/1990')
        self.selenium.find_element_by_xpath('//*[@id="id_activity_type"]/li[2]/label').click()
        self.selenium.find_element_by_xpath('//*[@id="id_activity_type"]/li[3]/label').click()
        self.selenium.find_element_by_xpath('//*[@id="id_learned_objective"]/li[6]/label').click()
        self.selenium.find_element_by_name('activity_adviser').send_keys('Cat')
        self.selenium.find_element_by_name('advisor_phone').send_keys('1234567890')
        self.selenium.find_element_by_name('advisor_email').send_keys('*****@*****.**')
        self.selenium.find_element_by_link_text('Back').click()
        self.selenium\
            .find_element_by_xpath("//img[@src='/static/journal/activities/img"
                                   "/journal_sign.png']")

    def test_activity_form_error(self):
        """Tests to check errors on the activity form"""
        self.selenium.find_element_by_xpath("/html/body/div[1]/div[2]/div/div[1]/div/div[2]/div/a").click()
        # self.selenium.find_element_by_name('activity_name').send_keys('')
        self.selenium.find_element_by_name('activity_description').send_keys('Walking with huahua around the neighborhood')
        self.selenium.find_element_by_xpath('/html/body/div[1]/div[2]/div[1]/form/div[2]/div[2]/input').send_keys('02/07/1990')
        self.selenium.find_element_by_xpath('//*[@id="id_activity_type"]/li[2]/label').click()
        self.selenium.find_element_by_xpath('//*[@id="id_activity_type"]/li[3]/label').click()
        self.selenium.find_element_by_xpath('//*[@id="id_learned_objective"]/li[6]/label').click()
        self.selenium.find_element_by_name('activity_adviser').send_keys('Cat')
        self.selenium.find_element_by_name('advisor_phone').send_keys('1234567890')
        self.selenium.find_element_by_name('advisor_email').send_keys('*****@*****.**')
        self.selenium.find_element_by_xpath('/html/body/div[1]/div[2]/div[1]/form/div[6]/div/input').click()
        self.selenium.find_element_by_name('activity_description').text

    def test_activity_form(self):
        """Tests to ensure that activities page has all necessary elements."""
        self.selenium.find_element_by_xpath("/html/body/div[1]/div[2]/div/div[1]/div/div[2]/div/a").click()
        self.selenium.find_element_by_name('activity_name').send_keys('Walking the cat')
        self.selenium.find_element_by_name('activity_description').send_keys('Walking the cat around the neighborhood')
        self.selenium.find_element_by_xpath('/html/body/div[1]/div[2]/div[1]/form/div[2]/div[2]/input').send_keys('02/07/1990')
        self.selenium.find_element_by_xpath('//*[@id="id_activity_type"]/li[2]/label').click()
        self.selenium.find_element_by_xpath('//*[@id="id_activity_type"]/li[3]/label').click()
        self.selenium.find_element_by_xpath('//*[@id="id_learned_objective"]/li[6]/label').click()
        self.selenium.find_element_by_name('activity_adviser').send_keys('Cat')
        self.selenium.find_element_by_name('advisor_phone').send_keys('1234567890')
        self.selenium.find_element_by_name('advisor_email').send_keys('*****@*****.**')
        self.selenium.find_element_by_xpath('/html/body/div[1]/div[2]/div[1]/form/div[6]/div/input').click()
        self.selenium\
            .find_element_by_xpath("//img[@src='/static/journal/activities/img"
                                   "/journal_sign.png']")
        body_text = self.selenium.find_element_by_tag_name('body').text
        self.assertTrue('Walking the cat' in body_text)
        self.assertTrue('Walking the cat around the neighborhood' in body_text)
Exemplo n.º 44
0
def syn_test_script():
    try:
        success = True
        driver = WebDriver()
        driver.implicitly_wait(30)
        # Disabled page sizing and instead used action chains to move mouse around
        # driver.set_window_size(1920, 1080)

        # Use Action chains to navigate page when there is an issue with the selection menus
        # If the menu item does not appear to select, it means there was a page movement that happened
        # out of sync with the action.

        log_output(
            "Starting @ http://www.kay.com/en/kaystore/searchterm/732541000/true/732541000"
        )
        driver.get(
            "http://www.kay.com/en/kaystore/searchterm/732541000/true/732541000"
        )

        log_output("Verify Search Results on page")
        html_text = driver.find_element_by_tag_name("html").text
        if not ("Home Search Results" in html_text):
            success = False
            print("verifyTextPresent failed")

        log_output("Click on first item - using div tag")
        driver.find_element_by_xpath(
            "//div[@id='product-grid']/div[1]/div/a/h3").click()

        log_output("Start customizing ring")
        driver.find_element_by_xpath(
            "//div[@class='m-vcb-content-html-modifier']//button[.='Start Customizing']"
        ).click()

        log_output("Choose number of stones and birth Stone")

        if not driver.find_element_by_xpath(
                "//select[@id='birthStoneSelect']//option[2]").is_selected():
            driver.find_element_by_xpath(
                "//select[@id='birthStoneSelect']//option[2]").click()
        driver.find_element_by_id("btnStartCustomizing").click()

        log_output("Step - Select Stone Type")
        ActionChains(driver).move_to_element(
            driver.find_element_by_css_selector("span.month_text")).perform()
        driver.find_element_by_css_selector("span.month_text").click()
        driver.find_element_by_xpath(
            "//div[@id='tab-stones-1']/div/ul/li[1]/label").click()
        if not driver.find_element_by_name("stoneId1").is_selected():
            driver.find_element_by_name("stoneId1").click()
        driver.find_element_by_link_text("SELECT").click()
        driver.find_element_by_xpath("//div[@id='cs']//a[.='Next']").click()

        log_output("Step - Select Metal Type")
        if not driver.find_element_by_xpath(
                "//select[@id='metalTypeSelect']//option[2]").is_selected():
            driver.find_element_by_xpath(
                "//select[@id='metalTypeSelect']//option[2]").click()
        log_output("clicking next")
        driver.find_element_by_xpath("//div[@id='m']//a[.='Next']").click()

        log_output("Step - Select ring size")
        if not driver.find_element_by_xpath(
                "//select[@id='sizeSelect']//option[2]").is_selected():
            driver.find_element_by_xpath(
                "//select[@id='sizeSelect']//option[2]").click()
        ActionChains(driver).move_to_element(
            driver.find_element_by_xpath(
                "//div[@id='rs']//a[.='Next']")).perform()
        next_click = driver.find_element_by_xpath(
            "//div[@id='rs']//a[.='Next']")
        next_click.click()
        ActionChains(driver).move_to_element(
            driver.find_element_by_xpath(
                "//div[@id='engr']//a[.='Next']")).perform()
        driver.find_element_by_xpath("//div[@id='engr']//a[.='Next']").click()

        log_output("Step - Add item to bag")
        driver.find_element_by_id("addToCart").click()
        # driver.find_element_by_link_text("ADD TO BAG").click()

        log_output("Step - Goto Checkout")
        driver.find_element_by_link_text("CHECKOUT").click()

        log_output("Verify text on page - Shopping Bag")
        html_text = driver.find_element_by_tag_name("html").text
        if not ("Shopping Bag" in html_text):
            success = False
            print("verifyTextPresent failed")

    finally:
        driver.quit()
        if not success:
            raise Exception("Test failed.")
Exemplo n.º 45
0
Arquivo: tests.py Projeto: astucse/SAS
class RegisteredUserTest(LiveServerTestCase):
    """
    Test as a registered user
    """
    def setUp(self):
        self.browser = WebDriver()
        self.browser.implicitly_wait(3)
        self.n1 = Node.objects.create(title='TestNodeOne',
                                      description='The first test node')
        self.u1 = User.objects.create_user(username='******',
                                           email='*****@*****.**',
                                           password='******')
        self.u2 = User.objects.create_user(username='******',
                                           email='*****@*****.**',
                                           password='******')

        # Create 198 topics
        for i in range(1, 100):
            setattr(
                self, 't%s' % i,
                Topic.objects.create(title='Test Topic %s' % i,
                                     user=self.u1,
                                     content_raw='This is test topic __%s__' %
                                     i,
                                     node=self.n1))

        for i in range(100, 199):
            setattr(
                self, 't%s' % i,
                Topic.objects.create(title='Test Topic %s' % i,
                                     user=self.u2,
                                     content_raw='This is test topic __%s__' %
                                     i,
                                     node=self.n1))

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

    def test_edit_own_topic(self):
        self.browser.get(self.live_server_url + reverse('index'))
        login(self.browser, "test1", "111")
        self.assertIn("Log out", self.browser.page_source)
        own_topic = getattr(self, "t%s" % (random.choice(range(1, 100))))
        self.browser.get(self.live_server_url +
                         reverse("topic", kwargs={"pk": own_topic.id}))
        self.browser.find_element_by_link_text("Edit").click()
        content_raw = self.browser.find_element_by_name("content_raw")
        content_raw.clear()
        content_raw.send_keys("This topic is edited")
        self.browser.find_element_by_name("submit").click()
        self.assertIn("This topic is edited", self.browser.page_source)

    def test_edit_others_topic(self):
        self.browser.get(self.live_server_url + reverse('index'))
        login(self.browser, "test1", "111")
        self.assertIn("Log out", self.browser.page_source)
        others_topic = getattr(self, "t%s" % (random.choice(range(100, 199))))
        self.browser.get(self.live_server_url +
                         reverse("topic", kwargs={"pk": others_topic.id}))
        self.assertNotIn("<span class=\"label label-success\">Edit</span>",
                         self.browser.page_source)
        self.browser.get(self.live_server_url +
                         reverse("edit_topic", kwargs={"pk": others_topic.id}))
        self.assertIn("You are not allowed to edit other's topic",
                      self.browser.page_source)

    def test_reply_topic(self):
        self.browser.get(self.live_server_url + reverse('index'))
        login(self.browser, "test1", "111")
        self.assertIn("Log out", self.browser.page_source)
        topic = getattr(self, "t%s" % (random.choice(range(1, 199))))
        self.browser.get(self.live_server_url +
                         reverse("topic", kwargs={"pk": topic.id}))
        content_raw = self.browser.find_element_by_name("content_raw")
        content_raw.clear()
        content_raw.send_keys("This is a reply")
        self.browser.find_element_by_name("submit").click()
        self.assertIn("This is a reply", self.browser.page_source)

    def test_closed_topic(self):
        self.browser.get(self.live_server_url + reverse('index'))
        login(self.browser, "test1", "111")
        self.assertIn("Log out", self.browser.page_source)
        topic = getattr(self, "t%s" % (random.choice(range(1, 199))))
        topic.closed = True
        topic.save()
        self.browser.get(self.live_server_url +
                         reverse("topic", kwargs={"pk": topic.id}))
        self.assertIn(_("This topic is closed"), self.browser.page_source)

    def test_create_topic(self):
        self.browser.get(self.live_server_url + reverse('index'))
        login(self.browser, "test1", "111")
        self.assertIn("Log out", self.browser.page_source)
        self.browser.get(self.live_server_url + reverse("create_topic"))
        node = self.browser.find_element_by_name("node")
        node = Select(node)
        title = self.browser.find_element_by_name("title")
        content_raw = self.browser.find_element_by_name("content_raw")
        node.select_by_visible_text(self.n1.title)
        title.send_keys("test title")
        content_raw.send_keys("this is content")
        self.browser.find_element_by_name("submit").click()
        self.assertIn("this is content", self.browser.page_source)

    def test_create_appendix(self):
        self.browser.get(self.live_server_url + reverse('index'))
        login(self.browser, "test1", "111")
        self.assertIn("Log out", self.browser.page_source)
        own_topic = getattr(self, "t%s" % (random.choice(range(1, 100))))
        self.browser.get(self.live_server_url +
                         reverse("topic", kwargs={"pk": own_topic.id}))
        self.browser.find_element_by_link_text("Append").click()
        content_raw = self.browser.find_element_by_name("content_raw")
        content_raw.clear()
        content_raw.send_keys("This is an appendix")
        self.browser.find_element_by_name("submit").click()
        self.assertIn("This is an appendix", self.browser.page_source)
def is_alert_present(wd):
    try:
        wd.switch_to_alert().text
        return True
    except:
        return False


try:
    login_obj = LoginPage(wd)
    sMessage = login_obj.login("*****@*****.**", "password")
    if sMessage is True:
        wd.find_element_by_xpath(
            "//div[@class='container']//a[.='Request a test']").click()
        wd.find_element_by_link_text(
            "I'd like to use a different address").click()
        wd.find_element_by_id("shipping_address_line1").click()
        wd.find_element_by_id("shipping_address_line1").clear()
        wd.find_element_by_id("shipping_address_line1").send_keys("3275 NW")
        wd.find_element_by_id("shipping_address_line2").click()
        wd.find_element_by_id("shipping_address_line2").clear()
        wd.find_element_by_id(
            "shipping_address_line2").send_keys("24th Street Rd")
        wd.find_element_by_id("shipping_address_city").click()
        wd.find_element_by_id("shipping_address_city").clear()
        wd.find_element_by_id("shipping_address_city").send_keys("Miami")
        if not wd.find_element_by_xpath("//select[@id='shipping_address_state']//option[11]").is_selected():
            wd.find_element_by_xpath("//select[@id='shipping_address_state']//option[11]").click()
            wd.find_element_by_id("shipping_address_zip").click()
            wd.find_element_by_id("shipping_address_zip").clear()
            wd.find_element_by_id("shipping_address_zip").send_keys("33344")