예제 #1
0
    def test_login_and_edit(self):
        self.driver.get(self.base + "/Fedora_Project_Wiki")
        assert title_is(self.title), self.driver.title
        elem = self.driver.find_element_by_id("pt-login")
        elem.click()

        assert title_is("Log in - " + self.title), self.driver.title
        elem = self.driver.find_element_by_id("wpName1")
        elem.send_keys(self.auth[0])
        elem = self.driver.find_element_by_id("wpPassword1")
        elem.send_keys(self.auth[1])
        elem = self.driver.find_element_by_id("wpLoginAttempt")
        elem.submit()

        assert title_is(self.title), self.driver.title

        self.driver.get(
            "https://stg.fedoraproject.org/wiki/Rube_Test_Page")
        elem = self.driver.find_element_by_id("ca-edit")
        elem.click()

        elem = self.driver.find_element_by_id("wpTextbox1")
        elem.send_keys(Keys.PAGE_DOWN)
        tag = str(uuid.uuid4())
        s = "Test comment from Rube\n%s" % tag
        elem.send_keys(s)
        elem = self.driver.find_element_by_id("wpSave")
        elem.submit()

        self.wait_for(tag)
예제 #2
0
 def test_9dReport(self):
     report = driver.find_element_by_link_text("Отчёты")
     report.click()
     time.sleep(1)
     # Отчёт по контрольным точкам
     report1 = driver.find_element_by_link_text("Отчёт по контрольным точкам")
     report1.click()
     title = wait.until(EC.title_is('ЭОР - Report'))
     assert "500" not in driver.title  # проверка на 500/404 ошибку
     assert "404" not in driver.title
     _ = wait.until(EC.element_to_be_clickable((By.ID, 'load_table')))
     assert "500" not in driver.title  # проверка на 500/404 ошибку
     assert "404" not in driver.title
     # Отчёт Проект Расписания
     schedule = driver.find_element_by_link_text('Отчёт Проект Расписания')
     schedule.click()
     _ = wait.until(EC.element_to_be_clickable((By.CLASS_NAME, 'title_gears')))
     title = wait.until(EC.title_is('ЭОР - Schedule'))
     assert "500" not in driver.title  # проверка на 500/404 ошибку
     assert "404" not in driver.title
     assert "ЭОР - Schedule" in driver.title
     # Отчёт Рейтинги
     rating = driver.find_element_by_link_text('Отчёт Рейтинги')
     rating.click()
     _ = wait.until(EC.element_to_be_clickable((By.CLASS_NAME, 'title_gears')))
     title = wait.until(EC.title_is('ЭОР - Rating'))
     assert "500" not in driver.title  # проверка на 500/404 ошибку
     assert "404" not in driver.title
     assert "ЭОР - Rating" in driver.title
예제 #3
0
    def test_login_and_edit_account(self):
        self.driver.get(self.base)
        assert title_is(self.title), self.driver.title
        elem = self.driver.find_element_by_link_text("Log In")
        elem.click()

        title = "Login to the Fedora Accounts System"
        assert title_is(title), self.driver.title
        elem = self.driver.find_element_by_name("user_name")
        elem.send_keys(self.auth[0])
        elem = self.driver.find_element_by_name("password")
        elem.send_keys(self.auth[1])
        elem = self.driver.find_element_by_name("login")
        elem.send_keys(Keys.ENTER)

        title = "Fedora Accounts System"
        assert title_is(title), self.driver.title

        elem = self.driver.find_element_by_link_text("My Account")
        elem.click()

        elem = self.driver.find_element_by_link_text("(edit)")
        elem.click()

        elem = self.driver.find_element_by_name("comments")
        elem.send_keys(Keys.PAGE_DOWN)
        tag = str(uuid.uuid4())
        s = "Test comment from Rube\n%s" % tag
        elem.send_keys(s)
        elem = self.driver.find_element_by_xpath(
            "/html/body/div/div[4]/div[2]/form/div[15]/input")
        elem.submit()

        self.wait_for(tag)
예제 #4
0
    def test_login_success(self):
        self.browser1 = webdriver.Firefox()
        self.browser2 = webdriver.Firefox()

        for i in range(100):
            # Step 1: Open the homepage of the installation
            self.browser1.get(url)
            self.browser2.get(url)

            # Step 2: Enter the username and the password in the login box
            loginpage1 = LoginPage(self.browser1)
            loginpage2 = LoginPage(self.browser2)
            loginpage1.login(user, password)
            loginpage2.login(user, password)

            # Step 3: Assert that the login is sucessful
            h1_1 = self.browser1.find_element_by_tag_name('h1')
            self.assertIn('Welcome', h1_1.text)
            h1_2 = self.browser2.find_element_by_tag_name('h1')
            self.assertIn('Welcome', h1_2.text)

            # Step 4: Logout
            self.browser1.get(url+"/identity/logout")
            self.browser2.get(url+"/identity/logout")

            wait = WebDriverWait(self.browser1, 10)
            wait.until(EC.title_is('Gluu'))
            wait = WebDriverWait(self.browser2, 10)
            wait.until(EC.title_is('Gluu'))

        self.browser1.quit()
        self.browser2.quit()
예제 #5
0
    def test_browser_navigation(self):
        driver = self.driver
        # get the search textbox
        search_field = driver.find_element_by_name("q")
        search_field.clear()

        # enter search keyword and submit
        search_field.send_keys("selenium webdriver")
        search_field.submit()

        se_wd_link = driver. \
            find_element_by_link_text("Selenium WebDriver")
        se_wd_link.click()
        self.assertEqual("Selenium WebDriver", driver.title)

        driver.back()
        self.assertTrue(WebDriverWait(self.driver, 10)
                        .until(expected_conditions.title_is("selenium webdriver - Google Search")))

        driver.forward()
        self.assertTrue(WebDriverWait(self.driver, 10)
                        .until(expected_conditions.title_is("Selenium WebDriver")))

        driver.refresh()
        self.assertTrue(WebDriverWait(self.driver, 10)
                        .until(expected_conditions.title_is("Selenium WebDriver")))
예제 #6
0
    def testBrowserNavigation(self):
        driver = self.driver
    # get the search textbox
        search_field = driver.find_element_by_name("q")
        search_field.clear()

    # enter search keyword and submit
        search_field.send_keys("selenium webdriver")
        search_field.submit();
        print("submittt...")

        se_wd_link = driver.find_element_by_link_text("Selenium WebDriver")
        se_wd_link.click()
        #self.assertEqual("selenium webdriver - Szukaj w Google", driver.title)

        
        print("do tyluu...")
        driver.back()
        self.assertTrue(WebDriverWait(self.driver, 10).until(expected_conditions.title_is("selenium webdriver - Szukaj w Google")))
        print("teraz do przodu")
        
        driver.forward()
        self.assertTrue(WebDriverWait(self.driver, 10).until(expected_conditions.title_is("Selenium WebDriver")))
        
        print("bedzie refresh")
        driver.refresh()
        self.assertTrue(WebDriverWait(self.driver, 10).until(expected_conditions.title_is("Selenium WebDriver")))
    def add_a_new_facility(self, facility):
        self.go_to_facilities()
        self.wait.until(EC.title_is('Facilities'))
        link = self.wait.until(EC.presence_of_element_located(
            (By.ID, 'id_add_new_facility_link')))
        link.click()
        self.wait.until(EC.title_is('Add New Facility'))
        inputbox = self.wait.until(
            EC.presence_of_element_located((By.ID, 'id_facility_name')))
        inputbox.send_keys(facility.name)
        self.browser.find_element_by_xpath(
            '//select[@id="id_facility_type"]/option[text()="%s"]' %
            facility.type).click()
        inputbox = self.wait.until(
            EC.presence_of_element_located((By.ID, 'id_facility_status')))
        inputbox.send_keys(facility.status)
        if facility.area:
            select = Select(self.browser.find_element_by_id('id_facility_area'))
            select.select_by_visible_text(unicode(facility.area))
        if facility.json:
            inputbox = self.wait.until(
                EC.presence_of_element_located((By.ID, 'id_json')))
            inputbox.send_keys(facility.json)

        submit = self.browser.find_element_by_id('id_submit_button')
        submit.click()
        self.wait.until(EC.title_is('Facilities'))
예제 #8
0
    def test_browser_navigation(self):
        #driver = self.driver
        # get the search textbox
        search_field = self.driver.find_element_by_name('q')
        search_field.clear()

        # enter search keyword and submit
        search_field.send_keys('selenium webdriver')
        search_field.submit()

        se_wd_link = self.driver.find_element_by_link_text('Selenium WebDriver')
        se_wd_link.click()
        self.assertTrue(WebDriverWait(self.driver, 10)
                        .until(EC.title_is('Selenium WebDriver')))

        self.driver.back()
        self.assertTrue(WebDriverWait(self.driver, 10)
                        .until(EC.title_contains('selenium webdriver - ')))

        self.driver.forward()
        self.assertTrue(WebDriverWait(self.driver, 10)
                        .until(EC.title_is('Selenium WebDriver')))

        self.driver.refresh()
        self.assertTrue(WebDriverWait(self.driver, 10)
                        .until(EC.title_is('Selenium WebDriver')))
예제 #9
0
 def testExpectedConditionTitleIs(self, driver, pages):
     pages.load("blank.html")
     WebDriverWait(driver, 1).until(EC.title_is("blank"))
     driver.execute_script("setTimeout(function(){document.title='not blank'}, 200)")
     WebDriverWait(driver, 1).until(EC.title_is("not blank"))
     assert driver.title == 'not blank'
     with pytest.raises(TimeoutException):
         WebDriverWait(driver, 0.7).until(EC.title_is("blank"))
 def test_task_D5(self):
     # I want to display a view of my claim when I click on it in the list
     self._login_user()
     WebDriverWait(self.browser, 10).until(ec.presence_of_element_located((By.ID, 'view_claims_button')))
     self.browser.find_element_by_id('view_claims_button').click()
     WebDriverWait(self.browser, 10).until(ec.title_is('Claims View'))
     WebDriverWait(self.browser, 10).until(ec.presence_of_element_located((By.CLASS_NAME, 'clickable-row')))
     self.browser.find_element_by_class_name('clickable-row').click()
     WebDriverWait(self.browser, 10).until(ec.title_is('View Claim'))
 def test_task_D8(self):
     # I want to be able to delete a claim
     self._login_user()
     WebDriverWait(self.browser, 10).until(ec.presence_of_element_located((By.ID, 'view_claims_button')))
     self.browser.find_element_by_id('view_claims_button').click()
     WebDriverWait(self.browser, 10).until(ec.title_is('Claims View'))
     self.browser.find_element_by_class_name('clickable-row').click()
     WebDriverWait(self.browser, 10).until(ec.title_is('View Claim'))
     self.browser.find_element_by_id('id_delete_claim_button').click()
     WebDriverWait(self.browser, 10).until(ec.title_is('Home'))
예제 #12
0
 def test_login(self):
   from selenium.common.exceptions import TimeoutException
   dbHelp.create_test_user_using_default_values()
   self.loginEmail.send_keys("[email protected]")
   self.loginPw.send_keys("123456")
   self.loginButton.click()
   WebDriverWait(self.driver,10).until(EC.title_is("Space Habit Frontier!"))
   self.assertEqual(self.driver.title,"Space Habit Frontier!")
   self.driver.get("http://127.0.0.1:8080/login")
   self.assertRaises(TimeoutException,lambda :WebDriverWait(self.driver,5).until(EC.title_is("Login to Space Habit Frontier")))
예제 #13
0
 def testExpectedConditionTitleIs(self, driver, pages):
     if driver.capabilities['browserName'] == 'firefox' and driver.w3c:
         pytest.xfail("Marionette issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1297551")
     pages.load("blank.html")
     WebDriverWait(driver, 1).until(EC.title_is("blank"))
     driver.execute_script("setTimeout(function(){document.title='not blank'}, 200)")
     WebDriverWait(driver, 1).until(EC.title_is("not blank"))
     assert driver.title == 'not blank'
     with pytest.raises(TimeoutException):
         WebDriverWait(driver, 0.7).until(EC.title_is("blank"))
 def testExpectedConditionTitleIs(self):
     self._loadPage("blank")
     WebDriverWait(self.driver, 1).until(EC.title_is("blank"))
     self.driver.execute_script("setTimeout(function(){document.title='not blank'}, 200)")
     WebDriverWait(self.driver, 1).until(EC.title_is("not blank"))
     self.assertEqual(self.driver.title, 'not blank')
     try:
         WebDriverWait(self.driver, 0.7).until(EC.title_is("blank"))
         self.fail("Expected TimeoutException to have been thrown")
     except TimeoutException as e:
         pass
 def test_taskb_story3(self):
     # Task b Story 3
     # As a normal user I want log into the system but not be able to access the admin section
     self.browser.get('{}{}'.format(self.live_server_url, '/admin/login/'))
     self.assertTrue(WebDriverWait(self.browser, 10).until(ec.title_is('Log in | Django site admin')))
     user_id = self.browser.find_element_by_id('id_username')
     user_password = self.browser.find_element_by_id('id_password')
     user_id.send_keys(USER1)
     user_password.send_keys(PASSWORD)
     user_password.send_keys(Keys.ENTER)
     self.assertTrue(WebDriverWait(self.browser, 10).until(ec.title_is('Log in | Django site admin')))
     self.browser.get('{}{}'.format(self.live_server_url, '/admin/logout/'))
 def test_task_C7(self):
     # test_profile_update
     # Task C7.	As a logged in user I want to be able to change my staff number and managers email
     self._login_user()
     self.browser.find_element_by_id('id_account').click()
     self.assertTrue(WebDriverWait(self.browser, 10).until(ec.title_is('Profile')))
     self.browser.find_element_by_id('id_staff_number').send_keys('54321')
     action_chains = ActionChains(self.browser)
     action_chains.double_click(self.browser.find_element_by_id('id_manager_email')).perform()
     self.browser.find_element_by_id('id_manager_email').send_keys(MANAGER2)
     self.browser.find_element_by_id('update_profile_button').click()
     self.assertTrue(WebDriverWait(self.browser, 10).until(ec.title_is('Home')))
예제 #17
0
 def testTitleEn(self):
     driver = self.driver
     driver.get(self.address)
     elementTitle = WebDriverWait(driver, 10).until(
         EC.title_is(u'Денисенко Денис')
     )
     eButtonEn = driver.find_element(By.XPATH, '//div[@class="block border indent header"]/div/a[@href="#en"]')
     eButtonEn.send_keys(Keys.ENTER)
     elementTitle = WebDriverWait(driver, 10).until(
         EC.title_is(u'Denisenko Denis')
     )
     driver.close()
 def test_task_C6(self):
     # Task C story 6
     # As a registered staff user I want to be able to log in and access the admin backend
     self.browser.get('{}{}'.format(self.live_server_url, ''))
     self.assertTrue(WebDriverWait(self.browser, 10).until(ec.title_is('Login')))
     user_id = self.browser.find_element_by_id('id_username')
     user_password = self.browser.find_element_by_id('id_password')
     user_id.send_keys(HR_USER)
     user_password.send_keys(PASSWORD)
     user_password.send_keys(Keys.ENTER)
     self.assertTrue(WebDriverWait(self.browser, 10).until(ec.title_is('Home')))
     self.browser.find_element_by_id('id_admin').click()
     self.assertTrue(WebDriverWait(self.browser, 10).until(ec.title_is('Site administration | Django site admin')))
예제 #19
0
 def test_amvr(self): 
     driver = self.driver
     waiting = self.waiting
     
     driver.get("https://apps.tn.gov/amvr-app/login.html")
     
     waiting.until(expected_conditions.title_is("Log In - Motor Vehicle Records Search"))
     username_textbox = waiting.until(expected_conditions.visibility_of(driver.find_element_by_id("username")))
     password_textbox = waiting.until(expected_conditions.visibility_of(driver.find_element_by_id("password")))
     login_button = waiting.until(expected_conditions.visibility_of(driver.find_element_by_name("login")))
     
     waiting.until(expected_conditions.title_is("Log In - Motor Vehicle Records Search"))
     self.assertIn("amvr-app/login.html", driver.current_url, "Failed to login")
 def test_task_C8(self):
     # Task C story 8
     # As a logged in user I want to be able to change my password
     self._login_user()
     self.browser.find_element_by_id('id_account').click()
     self.assertTrue(WebDriverWait(self.browser, 10).until(ec.title_is('Profile')))
     self.browser.find_element_by_id('id_change_password').click()
     self.assertTrue(WebDriverWait(self.browser, 10).until(ec.title_is('Password Change Form')))
     self.browser.find_element_by_id('id_old_password').send_keys(PASSWORD)
     self.browser.find_element_by_id('id_new_password1').send_keys(PASSWORD)
     self.browser.find_element_by_id('id_new_password2').send_keys(PASSWORD)
     self.browser.find_element_by_xpath('//input[@value="Change my password"]').click()
     self.assertTrue(WebDriverWait(self.browser, 10).until(ec.title_is('Password changed')))
 def test_taskb_story2(self):
     # Task b Story 2
     # As a super user I want log into the system and access the admin section of the project
     self.browser.get('{}{}'.format(self.live_server_url, '/admin/login/'))
     self.assertTrue(WebDriverWait(self.browser, 10).until(ec.title_is('Log in | Django site admin')))
     user_id = self.browser.find_element_by_id('id_username')
     user_password = self.browser.find_element_by_id('id_password')
     user_id.send_keys(SUPER_USER)
     user_password.send_keys(PASSWORD)
     user_password.send_keys(Keys.ENTER)
     self.assertTrue(WebDriverWait(self.browser, 10).until(ec.title_is('Site administration | Django site admin')))
     self.browser.get('{}{}'.format(self.live_server_url, '/admin/logout/'))
     self.assertTrue(WebDriverWait(self.browser, 10).until(ec.title_is('Logged out | Django site admin')))
 def test_task_D7(self):
     # I want to be able to update my claim when viewed if not authorised
     self._login_user()
     WebDriverWait(self.browser, 10).until(ec.presence_of_element_located((By.ID, 'view_claims_button')))
     self.browser.find_element_by_id('view_claims_button').click()
     WebDriverWait(self.browser, 10).until(ec.title_is('Claims View'))
     self.browser.find_element_by_class_name('clickable-row').click()
     WebDriverWait(self.browser, 10).until(ec.title_is('View Claim'))
     self.browser.find_element_by_id('id_authorising_manager').click()
     self.browser.find_element_by_id('id_authorising_manager').send_keys(Keys.ARROW_DOWN)
     self.browser.find_element_by_id('id_authorising_manager').send_keys(Keys.ARROW_DOWN)
     self.browser.find_element_by_id('id_authorising_manager').click()
     self.browser.find_element_by_id('id_save_claim_button').click()
     WebDriverWait(self.browser, 10).until(ec.title_is('Home'))
 def test_task_C5(self):
     # Task C story 5
     # As a registered user I want to be able to log in
     self.browser.get('{}{}'.format(self.live_server_url, ''))
     self.assertTrue(WebDriverWait(self.browser, 10).until(ec.title_is('Login')))
     user_id = self.browser.find_element_by_id('id_username')
     user_password = self.browser.find_element_by_id('id_password')
     user_id.send_keys(USER1)
     user_password.send_keys(PASSWORD)
     user_password.send_keys(Keys.ENTER)
     self.assertTrue(WebDriverWait(self.browser, 10).until(ec.title_is('Home')))
     logout_link = self.browser.find_element_by_id('id_logout')
     logout_link.click()
     self.assertTrue(WebDriverWait(self.browser, 10).until(ec.title_is('Logged Out')))
예제 #24
0
def title_is(driver, title, timeout=3):
    try:
        w = WebDriverWait(driver, timeout)
        w.until(EC.title_is(title))
        return True
    except TimeoutException:
        return False
예제 #25
0
    def reviewboard_login(self, username, password, verify=True):
        """Log into Review Board with the specified credentials."""
        # Ensure that we're logged out of both Review Board and Bugzilla;
        # otherwise we will be automatically logged back in.
        self.load_rburl('mozreview/logout/')
        self.load_bzurl('index.cgi?logout=1')
        self.load_rburl('account/login/')

        # Wait for redirect to Bugzilla login.
        bz_auth_url_path = 'auth.cgi?%s' % urlencode({
            'callback': '%smozreview/bmo_auth_callback/' % self.rburl,
            'description': 'mozreview'
        })
        bz_auth_url = '%s%s' % (self.bzurl, bz_auth_url_path)

        for _ in xrange(0, 5):
            if self.browser.current_url == bz_auth_url:
                break
            time.sleep(1)

        self.verify_bzurl(bz_auth_url_path)

        input_username = self.browser.find_element_by_id('Bugzilla_login')
        input_username.send_keys(username)
        input_password = self.browser.find_element_by_id('Bugzilla_password')
        input_password.send_keys(password)

        input_password.submit()

        if verify:
            WebDriverWait(self.browser, 10).until(
                EC.title_is(u'My Dashboard | Review Board'))
def _get_certificate_pdf_links(bin):
    """
    Given a BIN, returns the name of the PDF of the corresponding with the CO associated with that BIN.
    This data is taken from the NYC Department of Buildings (DOB) Building Information System (BIS),
    a web application hooked up into the DOB master building mainframe that first went live in 2001. The BIS allows
    one to look up all of the information DOB has on the building in question by address or BIN; information
    includes size, construction, permits, violations, fines, and so on.
    Since the URL which encodes this information is attached to a BIN, we can quickly locate the BIS page for a
    building by its BIN. The "List Certificates of Occupation" page, attached to this page by a link, is similarly
    easy to access.
    The trouble is that the application is rather old and cranky, so access to it is regulated by a load balancing
    access pane which # prints a webpage telling you you're going to have to wait a bit when load is high. A simple
    web scraper (e.g. requests) would scrape that load-balancing page and report back a failure, which we don't
    want (if you want to see the wait screen yourself I saved a screenshot of it at wait_screen.png, have a gander).
    I used the Python binding of selenium to get around this. Selenium is a full-fledged browser virtualizer that
    has a lot of additional capacities---the one we're using here is the ability to wait until the page reloads
    and the loading pane is gone.
    Note that the selenium instance used here requires PhantomJS to work. PhantomJS is a so-called "headless
    browser" which is like an ordinary browser like Firefox, except it doesn't bother displaying the pages,
    allowing it to go through page scrapes (as here) more efficiency.
    Once we have the page HTML I scape that using BeautifulSoup to get the PDF link.
    """
    req_str = "http://a810-bisweb.nyc.gov/bisweb/COsByLocationServlet?requestid=&allbin={0}".format(bin)
    _driver.get(req_str)
    print("Requested BIN {0} data from BIS, awaiting response...".format(bin))
    try:
        webdriver.support.ui.WebDriverWait(_driver, 10).until(
            EC.title_is("Property Overview")
        )
    finally:
        # print("Got a response.")
        raw_html = _driver.find_element_by_tag_name("body").get_attribute('innerHTML')
        dom = bs4.BeautifulSoup(raw_html, 'html.parser')
        return [str(link.text) for link in dom.select("a[href]") if "PDF" in link.text or "pdf" in link.text]
 def wait_for_title_present(self, title, seconds):
     try:
         is_present = WebDriverWait(self.driver, seconds).until(
             EC.title_is(title))
     except TimeoutException:
         is_present = False
     return is_present
예제 #28
0
파일: tests.py 프로젝트: Batterii/velruse
 def test_it(self):
     browser.get(self.login_url)
     self.assertEqual(browser.title, 'Auth Page')
     browser.find_element_by_id('github').submit()
     self.assertEqual(browser.title,
                      b'Sign in \xc2\xb7 GitHub'.decode('utf-8'))
     form = browser.find_element_by_id('login')
     login = form.find_element_by_name('login')
     login.send_keys(self.login)
     passwd = form.find_element_by_name('password')
     passwd.send_keys(self.password)
     form.find_element_by_name('commit').submit()
     find_title = EC.title_is('Authorize access to your account')
     find_result = EC.presence_of_element_located((By.ID, 'result'))
     WebDriverWait(browser, 2).until(
         lambda driver: find_title(driver) or find_result(driver))
     if browser.title == 'Authorize access to your account':
         btn = WebDriverWait(browser, 2).until(
             EC.presence_of_element_located((By.NAME, 'authorize')))
         btn.click()
         result = WebDriverWait(browser, 2).until(
             EC.presence_of_element_located((By.ID, 'result')))
     else:
         result = browser.find_element_by_id('result')
     self.assertEqual(browser.title, 'Result Page')
     result = browser.find_element_by_id('result').text
     result = json.loads(result)
     self.assertTrue('profile' in result)
     self.assertTrue('credentials' in result)
     self.assertTrue('displayName' in result['profile'])
     self.assertTrue('accounts' in result['profile'])
예제 #29
0
    def sign_out(self):
        element = self.driver.find_element_by_link_text('Log out')
        element.click()

        WebDriverWait(self.driver, 10).until(
            expected_conditions.title_is('URLTeam Tracker')
        )
예제 #30
0
파일: tests.py 프로젝트: Batterii/velruse
 def test_it(self):
     browser.get(self.login_url)
     self.assertEqual(browser.title, 'Auth Page')
     browser.find_element_by_id('live').submit()
     WebDriverWait(browser, 2).until(
         EC.presence_of_element_located((By.NAME, 'login')))
     self.assertEqual(browser.title,
                      'Sign in to your Microsoft account')
     login = browser.find_element_by_name('login')
     login.send_keys(self.login)
     passwd = browser.find_element_by_name('passwd')
     passwd.send_keys(self.password)
     passwd.submit()
     find_title = EC.title_is('Allow access?')
     find_result = EC.presence_of_element_located((By.ID, 'result'))
     WebDriverWait(browser, 2).until(
         lambda driver: find_title(driver) or find_result(driver))
     if browser.title == 'Allow access?':
         btn = WebDriverWait(browser, 2).until(
             EC.presence_of_element_located((By.NAME, 'submitYes')))
         btn.click()
         result = WebDriverWait(browser, 2).until(
             EC.presence_of_element_located((By.ID, 'result')))
     else:
         result = browser.find_element_by_id('result')
     self.assertEqual(browser.title, 'Result Page')
     result = json.loads(result.text)
     self.assertTrue('profile' in result)
     self.assertTrue('credentials' in result)
     self.assertTrue('displayName' in result['profile'])
     self.assertTrue('accounts' in result['profile'])
def open_url(page_url, page_title):
    driver.maximize_window()
    driver.get(page_url)
    wait.until(EC.title_is(page_title))
    return driver
예제 #32
0
 def go_to_settings_page(self):
     self.driver.get(self.URL)
     _ = WebDriverWait(self.driver,
                       5).until(EC.title_is(SettingsFoldersPage.TITLE))
     return True
예제 #33
0
    def test_table_insert_row(self):
        # Login
        self.login('*****@*****.**')

        self.open(reverse('workflow:index'))

        # GO TO THE WORKFLOW PAGE
        WebDriverWait(self.selenium,
                      10).until(EC.title_is('OnTask :: Workflows'))
        self.assertIn('New Workflow', self.selenium.page_source)
        self.assertIn('Import Workflow', self.selenium.page_source)

        # Open the workflow
        wf_link = self.selenium.find_element_by_link_text(self.wflow_name)
        wf_link.click()
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'column-table_previous')))

        # Go to the table page
        wf_link = self.selenium.find_element_by_link_text('Table')
        wf_link.click()
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'table-data_previous')))

        # Click on the add button
        self.selenium.find_element_by_xpath(
            "//div[@id='table-content']/div/div/button[1]").click()
        self.selenium.find_element_by_link_text('Add row').click()

        # Fill out the fields in the form
        for x in range(0, 10):
            keyelem = self.selenium.find_element_by_id(
                'id____ontask___upload_{0}'.format(x))
            keyelem.clear()
            keyelem.send_keys(str(x))

        # Set c91 to true
        c91 = self.selenium.find_element_by_id('id____ontask___upload_10')
        self.assertFalse(c91.is_selected())
        c91.click()
        # Click on the Submit button
        self.selenium.find_element_by_xpath(
            "//form/button[@type='submit']").click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.CLASS_NAME, 'alert-danger')))

        # Incorrect primary key introduced (repeated value)
        self.assertIn('It must be different to maintain Key property',
                      self.selenium.page_source)

        # Introduce a valid primary key
        keyelem = self.selenium.find_element_by_id('id____ontask___upload_0')
        keyelem.clear()
        keyelem.send_keys('100')
        # Click on the Submit button
        self.selenium.find_element_by_xpath(
            "//form/button[@type='submit']").click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'table-data_previous')))

        # Go to page 11 of the table
        self.selenium.find_element_by_link_text('11').click()
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element((By.CLASS_NAME, 'sorting_1'),
                                             '100'))

        # Click in the Ops -> delete button -> Delete row
        self.selenium.find_element_by_xpath(
            "//tbody/tr/td/div/button[1]").click()
        self.selenium.find_element_by_xpath(
            "//tbody/tr/td/div/ul/li[3]/button").click()
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element((By.CLASS_NAME, 'modal-title'),
                                             'Confirm row deletion'))
        self.selenium.find_element_by_xpath(
            "//div[@id='modal-item']//button[@type='submit']").click()
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element((By.ID, 'table-data_info'),
                                             '1 to 10 of 100 entries'))

        # End of session
        self.logout()
예제 #34
0
    def test_table_create_derived_columns(self):
        # Login
        self.login('*****@*****.**')

        self.open(reverse('workflow:index'))

        # GO TO THE WORKFLOW PAGE
        WebDriverWait(self.selenium,
                      10).until(EC.title_is('OnTask :: Workflows'))
        self.assertIn('New Workflow', self.selenium.page_source)
        self.assertIn('Import Workflow', self.selenium.page_source)

        # Open the workflow
        wf_link = self.selenium.find_element_by_link_text(self.wflow_name)
        wf_link.click()
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'column-table_previous')))

        # Click in the add derived column button
        self.selenium.find_element_by_css_selector(
            "button.btn.btn-primary.btn-sm.js-workflow-formula-column-add"
        ).click()
        # Wait for the form to create the derived column
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Add derived column'))

        # Fill out the details for D1 = c1 + c2
        self.selenium.find_element_by_id("id_name").click()
        self.selenium.find_element_by_id("id_name").clear()
        self.selenium.find_element_by_id("id_name").send_keys("d1")
        self.selenium.find_element_by_css_selector(
            "div.sol-input-container > input[type=\"text\"]").click()
        self.selenium.find_element_by_id("id_op_type").click()
        Select(self.selenium.find_element_by_id(
            "id_op_type")).select_by_visible_text("sum: Sum selected columns")
        self.selenium.find_element_by_css_selector(
            "div.sol-input-container > input[type=\"text\"]").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[2]").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[3]").click()
        self.selenium.find_element_by_css_selector(
            "div.sol-current-selection").click()
        self.selenium.find_element_by_css_selector(
            "div.modal-footer > button.btn.btn-primary").click()
        # MODAL WAITING
        WebDriverWait(self.selenium, 10).until_not(
            EC.presence_of_element_located((By.CLASS_NAME, 'modal-open')))
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'column-table_previous')))

        # Click in the add derived column button
        self.selenium.find_element_by_css_selector(
            "button.btn.btn-primary.btn-sm.js-workflow-formula-column-add"
        ).click()
        # Wait for the form to create the derived column
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Add derived column'))

        # Fill out the details for D2 = c3 * c4
        self.selenium.find_element_by_id("id_name").click()
        self.selenium.find_element_by_id("id_name").clear()
        self.selenium.find_element_by_id("id_name").send_keys("d2")
        self.selenium.find_element_by_css_selector(
            "div.sol-input-container > input[type=\"text\"]").click()
        self.selenium.find_element_by_id("id_op_type").click()
        Select(
            self.selenium.find_element_by_id("id_op_type")
        ).select_by_visible_text("prod: Product of the selected columns")
        self.selenium.find_element_by_css_selector(
            "div.sol-input-container > input[type=\"text\"]").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[4]").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[5]").click()
        self.selenium.find_element_by_css_selector(
            "div.sol-current-selection").click()
        self.selenium.find_element_by_css_selector(
            "div.modal-footer > button.btn.btn-primary").click()
        # MODAL WAITING
        WebDriverWait(self.selenium, 10).until_not(
            EC.presence_of_element_located((By.CLASS_NAME, 'modal-open')))
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'column-table_previous')))

        # Click in the add derived column button
        self.selenium.find_element_by_css_selector(
            "button.btn.btn-primary.btn-sm.js-workflow-formula-column-add"
        ).click()
        # Wait for the form to create the derived column
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Add derived column'))

        # Fill out the details for D3 = max(c5, c6)
        self.selenium.find_element_by_id("id_name").click()
        self.selenium.find_element_by_id("id_name").clear()
        self.selenium.find_element_by_id("id_name").send_keys("d3")
        self.selenium.find_element_by_id("id_op_type").click()
        Select(self.selenium.find_element_by_id("id_op_type")
               ).select_by_visible_text("max: Maximum of the selected columns")
        self.selenium.find_element_by_css_selector(
            "div.sol-input-container > input[type=\"text\"]").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[6]").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[7]").click()
        self.selenium.find_element_by_css_selector("div.modal-body").click()
        self.selenium.find_element_by_css_selector(
            "div.modal-footer > button.btn.btn-primary").click()
        # MODAL WAITING
        WebDriverWait(self.selenium, 10).until_not(
            EC.presence_of_element_located((By.CLASS_NAME, 'modal-open')))
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'column-table_previous')))

        # Click in the add derived column button
        self.selenium.find_element_by_css_selector(
            "button.btn.btn-primary.btn-sm.js-workflow-formula-column-add"
        ).click()
        # Wait for the form to create the derived column
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Add derived column'))

        # Fill out the details for D4 = min(c7, c8)
        self.selenium.find_element_by_id("id_name").click()
        self.selenium.find_element_by_id("id_name").clear()
        self.selenium.find_element_by_id("id_name").send_keys("d4")
        self.selenium.find_element_by_id("id_op_type").click()
        Select(self.selenium.find_element_by_id("id_op_type")
               ).select_by_visible_text("min: Minimum of the selected columns")
        self.selenium.find_element_by_css_selector(
            "div.sol-input-container > input[type=\"text\"]").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[8]").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[9]").click()
        self.selenium.find_element_by_css_selector("div.modal-body").click()
        self.selenium.find_element_by_css_selector(
            "div.modal-footer > button.btn.btn-primary").click()
        # MODAL WAITING
        WebDriverWait(self.selenium, 10).until_not(
            EC.presence_of_element_located((By.CLASS_NAME, 'modal-open')))
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'column-table_previous')))

        # Click in the add derived column button
        self.selenium.find_element_by_css_selector(
            "button.btn.btn-primary.btn-sm.js-workflow-formula-column-add"
        ).click()
        # Wait for the form to create the derived column
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Add derived column'))

        # Fill out the details for D5 = mean(c1, c2)
        self.selenium.find_element_by_id("id_name").click()
        self.selenium.find_element_by_id("id_name").clear()
        self.selenium.find_element_by_id("id_name").send_keys("d5")
        self.selenium.find_element_by_css_selector(
            "div.sol-input-container > input[type=\"text\"]").click()
        self.selenium.find_element_by_id("id_op_type").click()
        Select(self.selenium.find_element_by_id("id_op_type")
               ).select_by_visible_text("mean: Mean of the selected columns")
        self.selenium.find_element_by_css_selector(
            "div.sol-input-container > input[type=\"text\"]").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[2]").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[3]").click()
        self.selenium.find_element_by_css_selector(
            "div.sol-current-selection").click()
        self.selenium.find_element_by_css_selector(
            "div.modal-footer > button.btn.btn-primary").click()
        # MODAL WAITING
        WebDriverWait(self.selenium, 10).until_not(
            EC.presence_of_element_located((By.CLASS_NAME, 'modal-open')))
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'column-table_previous')))

        # Click in the add derived column button
        self.selenium.find_element_by_css_selector(
            "button.btn.btn-primary.btn-sm.js-workflow-formula-column-add"
        ).click()
        # Wait for the form to create the derived column
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Add derived column'))

        # Fill out the details for D6 = median(c3, c4)
        self.selenium.find_element_by_id("id_name").click()
        self.selenium.find_element_by_id("id_name").clear()
        self.selenium.find_element_by_id("id_name").send_keys("d6")
        self.selenium.find_element_by_css_selector(
            "div.sol-input-container > input[type=\"text\"]").click()
        self.selenium.find_element_by_id("id_op_type").click()
        Select(
            self.selenium.find_element_by_id("id_op_type")
        ).select_by_visible_text("median: Median of the selected columns")
        self.selenium.find_element_by_css_selector(
            "div.sol-input-container > input[type=\"text\"]").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[4]").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[5]").click()
        self.selenium.find_element_by_css_selector(
            "div.sol-current-selection").click()
        self.selenium.find_element_by_css_selector(
            "div.modal-footer > button.btn.btn-primary").click()
        # MODAL WAITING
        WebDriverWait(self.selenium, 10).until_not(
            EC.presence_of_element_located((By.CLASS_NAME, 'modal-open')))
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'column-table_previous')))

        # Click in the add derived column button
        self.selenium.find_element_by_css_selector(
            "button.btn.btn-primary.btn-sm.js-workflow-formula-column-add"
        ).click()
        # Wait for the form to create the derived column
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Add derived column'))

        # Fill out the details for D7 = std(c5, c6)
        self.selenium.find_element_by_id("id_name").click()
        self.selenium.find_element_by_id("id_name").clear()
        self.selenium.find_element_by_id("id_name").send_keys("d7")
        self.selenium.find_element_by_id("id_op_type").click()
        Select(self.selenium.find_element_by_id(
            "id_op_type")).select_by_visible_text(
                "std: Standard deviation over the selected columns")
        self.selenium.find_element_by_css_selector(
            "div.sol-input-container > input[type=\"text\"]").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[6]").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[7]").click()
        self.selenium.find_element_by_css_selector("div.modal-body").click()
        self.selenium.find_element_by_css_selector(
            "div.modal-footer > button.btn.btn-primary").click()
        # MODAL WAITING
        WebDriverWait(self.selenium, 10).until_not(
            EC.presence_of_element_located((By.CLASS_NAME, 'modal-open')))
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'column-table_previous')))

        # Click in the add derived column button
        self.selenium.find_element_by_css_selector(
            "button.btn.btn-primary.btn-sm.js-workflow-formula-column-add"
        ).click()
        # Wait for the form to create the derived column
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Add derived column'))

        # Fill out the details for D8 = all(c91, c92)
        self.selenium.find_element_by_id("id_name").click()
        self.selenium.find_element_by_id("id_name").clear()
        self.selenium.find_element_by_id("id_name").send_keys("d8")
        self.selenium.find_element_by_id("id_op_type").click()
        Select(self.selenium.find_element_by_id(
            "id_op_type")).select_by_visible_text(
                "all: True when all elements in selected columns are true")
        self.selenium.find_element_by_css_selector(
            "div.sol-input-container > input[type=\"text\"]").click()
        # Wait for JS to do its thing
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.XPATH, "(//input[@name='columns'])[12]")))
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[11]").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[12]").click()
        self.selenium.find_element_by_css_selector("div.modal-body").click()
        self.selenium.find_element_by_css_selector(
            "div.modal-footer > button.btn.btn-primary").click()
        # MODAL WAITING
        WebDriverWait(self.selenium, 10).until_not(
            EC.presence_of_element_located((By.CLASS_NAME, 'modal-open')))
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'column-table_previous')))

        # Click in the add derived column button
        self.selenium.find_element_by_css_selector(
            "button.btn.btn-primary.btn-sm.js-workflow-formula-column-add"
        ).click()
        # Wait for the form to create the derived column
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Add derived column'))

        # Fill out the details for D9 = any(c91, c92)
        self.selenium.find_element_by_id("id_name").click()
        self.selenium.find_element_by_id("id_name").clear()
        self.selenium.find_element_by_id("id_name").send_keys("d9")
        self.selenium.find_element_by_id("id_op_type").click()
        Select(self.selenium.find_element_by_id(
            "id_op_type")).select_by_visible_text(
                "any: True when any element in selected columns is true")
        self.selenium.find_element_by_css_selector(
            "div.sol-input-container > input[type=\"text\"]").click()
        # Wait for JS to do its thing
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.XPATH, "(//input[@name='columns'])[12]")))
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[11]").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[12]").click()
        self.selenium.find_element_by_css_selector("div.modal-body").click()
        self.selenium.find_element_by_css_selector(
            "div.modal-footer > button.btn.btn-primary").click()
        # MODAL WAITING
        WebDriverWait(self.selenium, 10).until_not(
            EC.presence_of_element_located((By.CLASS_NAME, 'modal-open')))
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'column-table_previous')))

        # Check that the data is correct
        df = pandas_db.load_from_db(Workflow.objects.all()[0].id)

        # d1 = c1 + c2
        self.assertTrue((df['d1'] == df[['c1', 'c2']].sum(axis=1)).all())
        # d2 = c3 * c4
        self.assertTrue((df['d2'] == df[['c3', 'c4']].prod(axis=1)).all())
        # d3 = max(c5, c6)
        self.assertTrue((df['d3'] == df[['c5', 'c6']].max(axis=1)).all())
        # d4 = min(c7, c8)
        self.assertTrue((df['d4'] == df[['c7', 'c8']].min(axis=1)).all())
        # d5 = mean(c1, c2)
        self.assertTrue((df['d5'] == df[['c1', 'c2']].mean(axis=1)).all())
        # d6 = median(c3, c4)
        self.assertTrue((df['d6'] == df[['c3', 'c4']].median(axis=1)).all())
        # d7 = std(c5, c6) (error below 10^{-11})
        self.assertTrue(
            ((df['d7'] - df[['c5', 'c6']].std(axis=1)).abs() < 0.1e-12).all())
        # d8 = all(c91, c92)
        self.assertTrue((df['d8'] == df[['c91', 'c92']].all(axis=1)).all())
        # d9 = any(c91, c92)
        self.assertTrue((df['d9'] == df[['c91', 'c92']].any(axis=1)).all())

        # End of session
        self.logout()
예제 #35
0
    def test_action_02_condition(self):
        # Login
        self.login('*****@*****.**')

        self.open(reverse('workflow:index'))

        # GO TO THE WORKFLOW PAGE
        WebDriverWait(self.selenium,
                      10).until(EC.title_is('OnTask :: Workflows'))
        self.assertIn('New Workflow', self.selenium.page_source)
        self.assertIn('Import Workflow', self.selenium.page_source)

        # Open the workflow
        wf_link = self.selenium.find_element_by_link_text(self.wflow_name)
        wf_link.click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'wflow-name')))

        # Goto the action page
        self.selenium.find_element_by_link_text('Actions').click()
        # Wait for page to refresh (FLAKY)
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable((By.CLASS_NAME, 'js-create-action')))
        self.assertIn('New Action', self.selenium.page_source)

        # click in the action page
        self.selenium.find_element_by_link_text('Edit').click()
        # Wait for the action page
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.XPATH, "//div[@id='filter-set']/h4/div/button")))

        # Click in the add condition button
        self.selenium.find_element_by_xpath(
            "//div[@id='condition-set']/h4/button").click()
        # Wait for the form to appear
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Create condition'))

        # Add the name and description
        self.selenium.find_element_by_id('id_name').send_keys('c1')
        self.selenium.find_element_by_id('id_description_text').send_keys(
            'cdesc1')

        # Select the age filter
        sel = Select(
            self.selenium.find_element_by_name('builder_rule_0_filter'))
        sel.select_by_value('age')
        # Wait for the select elements to be clickable
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.XPATH, "//select[@name='builder_rule_0_filter']")))

        # Set the operator to less or equal
        sel = Select(
            self.selenium.find_element_by_name('builder_rule_0_operator'))
        sel.select_by_value('less_or_equal')

        # Set the value to 12.1
        self.selenium.find_element_by_name('builder_rule_0_value_0').send_keys(
            '12.1')

        # Click in the "update condition"
        self.selenium.find_element_by_xpath(
            "//div[@id='modal-item']/div/div/form/div/button[2]").click()
        # Wait for page to refresh (FLAKY)
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable((By.CLASS_NAME, 'js-condition-edit')))

        # Click in the add a second condition
        self.selenium.find_element_by_xpath(
            "//div[@id='condition-set']/h4/button").click()
        # Wait for the form to appear
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Create condition'))

        # Add the name and description
        self.selenium.find_element_by_id('id_name').send_keys('c2')
        self.selenium.find_element_by_id('id_description_text').send_keys(
            'cdesc2')

        # Select the age filter
        sel = Select(
            self.selenium.find_element_by_name('builder_rule_0_filter'))
        sel.select_by_value('age')
        # Wait for the select elements to be clickable
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.XPATH, "//select[@name='builder_rule_0_filter']")))

        # Set the operator to less or equal
        sel = Select(
            self.selenium.find_element_by_name('builder_rule_0_operator'))
        sel.select_by_value('greater')

        # Set the value to 12.1
        self.selenium.find_element_by_name('builder_rule_0_value_0').send_keys(
            '12.1')

        # Click in the "update condition"
        self.selenium.find_element_by_xpath(
            "//div[@id='modal-item']/div/div/form/div/button[2]").click()
        # Wait for page to refresh (FLAKY)
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable((By.CLASS_NAME, 'js-condition-edit')))

        # Action now has two complementary conditions, add the conditions to
        # the message
        self.selenium.execute_script("""$('#id_content').summernote(
                   'editor.insertText', 
                   "{% if c1 %}Low{% endif %}{% if c2 %}High{% endif %}")""")

        # Save the action
        self.selenium.find_element_by_xpath(
            "//div[@id='html-editor']/form/div[3]/button[2]").click()
        # This is a pure javascript submission, no other way to catch it
        time.sleep(5)
        # with self.wait_for_page_load(timeout=10):
        #     self.selenium.find_element_by_link_text('Details')

        # Click the preview button
        self.selenium.find_element_by_xpath(
            "//div[@id='html-editor']/form/div[3]/button[1]").click()
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.CLASS_NAME, 'js-action-preview-nxt')))

        # First value should be high age
        self.assertIn('Low', self.selenium.page_source)

        # Click in the next button
        self.selenium.find_element_by_class_name(
            'js-action-preview-nxt').click()

        # First value should be high age
        self.assertIn('Low', self.selenium.page_source)

        # Click in the next button
        self.selenium.find_element_by_class_name(
            'js-action-preview-nxt').click()

        # First value should be high age
        self.assertIn('High', self.selenium.page_source)

        # End of session
        self.logout()
예제 #36
0
파일: base.py 프로젝트: manasa94-git/Amazon
 def wait_for_title(self, driver, time):
     wait = WebDriverWait(driver, time)
     wait.until(ec.title_is("Amazon Sign In"), "Title not matched")
예제 #37
0
def page_has_loaded(driver):
    """
 页面是否加载完
    :param driver:
    :return:
    """
    page_state = driver.execute_script('return document.readyState;')
    return page_state == 'complete'


try:
    # 登录

    browser.get(url)
    wait30s.until(EC.title_is('首页-项目管理职业资格认证'))
    #BasePage = Page.BasePage
    element = browser.find_element_by_xpath(sign_entrance)
    element.click()
    # BasePage.click("xpath",sign_entrance)
    #wait30s.until(EC.title_is('会员登录-首页-项目管理职业资格认证'))
    time.sleep(1)
    username = browser.find_element_by_id(login_user)
    username.send_keys("chai1005")  # 请再这儿输入用户名!
    password = browser.find_element_by_id(login_password)
    time.sleep(1)
    password.send_keys("chai1005")  # 请再这儿输入密码!
    browser.find_element_by_id(login_button).click()
    # password.send_keys(Keys.ENTER)
    time.sleep(1)
    cookies = browser.get_cookies()
예제 #38
0
 def el_verify_title(self, expectedTitle):
     try:
         WebDriverWait(self.driver, 10).until(EC.title_is(expectedTitle))
     except BaseException:
         e = sys.exc_info()[0]
         print("!!! Exception: ", e)
예제 #39
0
 def wait_title(self, title):  # 判断title,返回布尔值
     WebDriverWait(self._driver, 10).until(EC.title_is(title))
예제 #40
0
 def click_sign_up_btn(self):
     self.driver.execute_script(
         """document.getElementsByTagName("a")[61].click();""")
     WebDriverWait(self.driver, 15).until(EC.title_is('Register'))
 def title_is_demo(self):
     title = WebDriverWait(self.driver,
                           10).until(EC.title_is("PChome 線上購物"))
     print(title)  # True
def test_02(driver):
    WebDriverWait(driver, 5).until(EC.title_is("My Store"))
예제 #43
0
 def is_me(self):
     return WebDriverWait(self.web_driver,
                          10).until(expected_conditions.title_is('创建课程'))
예제 #44
0
    def test_action_03_send_email(self):
        # Login
        self.login('*****@*****.**')

        self.open(reverse('workflow:index'))

        # GO TO THE WORKFLOW PAGE
        WebDriverWait(self.selenium,
                      10).until(EC.title_is('OnTask :: Workflows'))
        self.assertIn('New Workflow', self.selenium.page_source)
        self.assertIn('Import Workflow', self.selenium.page_source)

        # Open the workflow
        wf_link = self.selenium.find_element_by_link_text(self.wflow_name)
        wf_link.click()
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element((By.CLASS_NAME, 'page-header'),
                                             'Workflow Details'))
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable((By.CLASS_NAME, 'success')))

        # Goto the action page
        self.selenium.find_element_by_link_text('Actions').click()
        self.assertIn('New Action', self.selenium.page_source)

        # Click in the page to send email
        self.selenium.find_element_by_link_text('Email').click()

        # Set the subject of the email
        self.selenium.find_element_by_id('id_subject').send_keys('Subject TXT')
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element((By.CLASS_NAME, 'page-header'),
                                             'Send emails'))

        # Set the email column
        select = Select(self.selenium.find_element_by_id('id_email_column'))
        select.select_by_value('email')

        # Tick the track email
        self.selenium.find_element_by_id('id_track_read').click()

        # Tick add column
        self.selenium.find_element_by_id('id_add_column').click()

        # Click the send button
        self.selenium.find_element_by_class_name('btn-success').click()
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element((By.CLASS_NAME, 'page-header'),
                                             'Email action'))

        # There should be a message on that page
        self.assertIn('Emails successfully sent', self.selenium.page_source)

        # Go to the table page
        self.open(reverse('table:display'))
        # Wait for
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'table-data_previous')))

        # There should be a column for the email tracking
        self.assertIn('EmailRead_1', self.selenium.page_source)

        # Make sure the workflow is consistent
        pandas_db.check_wf_df(Workflow.objects.get(name=self.wflow_name))

        # End of session
        self.logout()
예제 #45
0
    def test_table_views(self):
        # Login
        self.login('*****@*****.**')

        self.open(reverse('workflow:index'))

        # GO TO THE WORKFLOW PAGE
        WebDriverWait(self.selenium,
                      10).until(EC.title_is('OnTask :: Workflows'))
        self.assertIn('New Workflow', self.selenium.page_source)
        self.assertIn('Import Workflow', self.selenium.page_source)

        # Open the workflow
        wf_link = self.selenium.find_element_by_link_text(self.wflow_name)
        wf_link.click()
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'column-table_previous')))

        # Open the Table view
        self.selenium.find_element_by_link_text("Table").click()

        # Open the Views menu
        self.selenium.find_element_by_link_text("Views").click()

        # Button to add a view
        self.selenium.find_element_by_css_selector(
            "button.btn.btn-sm.btn-primary.js-view-add").click()
        # Wait for the form to create the derived column
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Add view'))

        # Insert data to create the first view
        self.selenium.find_element_by_id("id_name").click()
        self.selenium.find_element_by_id("id_name").clear()
        self.selenium.find_element_by_id("id_name").send_keys("v1")
        self.selenium.find_element_by_css_selector(
            "div.sol-input-container > input[type=\"text\"]").click()
        self.selenium.find_element_by_name("columns").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[2]").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[3]").click()
        self.selenium.find_element_by_css_selector("div.modal-body").click()
        self.selenium.find_element_by_css_selector(
            "button.btn.btn-xs.btn-success").click()
        self.selenium.find_element_by_name("builder_rule_0_filter").click()
        Select(self.selenium.find_element_by_name(
            "builder_rule_0_filter")).select_by_visible_text("c1")
        self.selenium.find_element_by_name("builder_rule_0_value_0").click()
        self.selenium.find_element_by_name("builder_rule_0_value_0").clear()
        self.selenium.find_element_by_name("builder_rule_0_value_0").send_keys(
            "5")
        # Save the view
        self.selenium.find_element_by_css_selector(
            "div.modal-footer > button.btn.btn-primary").click()
        self.wait_close_modal_refresh_table('view-table_previous')

        # Click in the link to see the table resulting from this view
        self.selenium.find_element_by_css_selector(
            "a.btn.btn-primary.btn-sm").click()
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'table-data_previous')))

        # Check the number of entries
        self.assertIn(
            'Showing 1 to 10 of 13 entries (filtered from 100 total entries)',
            self.selenium.page_source)

        # Go back to the views page
        self.selenium.find_element_by_link_text("Views").click()
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'view-table_previous')))

        # Add a second view
        self.selenium.find_element_by_css_selector(
            "button.btn.btn-sm.btn-primary.js-view-add").click()
        # Wait for the form to create the derived column
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Add view'))

        # Add the details for the second view
        self.selenium.find_element_by_id("id_name").click()
        self.selenium.find_element_by_id("id_name").clear()
        self.selenium.find_element_by_id("id_name").send_keys("v2")
        self.selenium.find_element_by_css_selector(
            "div.sol-input-container > input[type=\"text\"]").click()
        self.selenium.find_element_by_name("columns").click()
        self.selenium.find_element_by_xpath(
            "//div[@id='div_id_columns']/div/div/div/div[3]/div[2]/label/div"
        ).click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[3]").click()
        self.selenium.find_element_by_id("div_id_columns").click()
        self.selenium.find_element_by_css_selector(
            "button.btn.btn-xs.btn-success").click()
        self.selenium.find_element_by_name("builder_rule_0_filter").click()
        Select(self.selenium.find_element_by_name(
            "builder_rule_0_filter")).select_by_visible_text("c2")
        self.selenium.find_element_by_name("builder_rule_0_operator").click()
        Select(self.selenium.find_element_by_name("builder_rule_0_operator")
               ).select_by_visible_text("greater or equal")
        self.selenium.find_element_by_name("builder_rule_0_value_0").click()
        self.selenium.find_element_by_name("builder_rule_0_value_0").clear()
        self.selenium.find_element_by_name("builder_rule_0_value_0").send_keys(
            "5")
        # Save the view
        self.selenium.find_element_by_css_selector(
            "div.modal-footer > button.btn.btn-primary").click()
        # MODAL WAITING
        self.wait_close_modal_refresh_table('view-table_previous')

        # Check the table resulting from the view
        self.selenium.find_element_by_css_selector(
            "tr.even > td.operations.dt-center > div.dropdown > a.btn.btn-primary.btn-sm"
        ).click()
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'table-data_previous')))

        # Check the number of entries
        self.assertIn(
            'Showing 1 to 10 of 42 entries (filtered from 100 total entries)',
            self.selenium.page_source)

        # Go back to the full table
        self.selenium.find_element_by_xpath(
            "//div[@id='table-content']/div[1]/button[2]").click()
        # Wait for the table to first deleted
        WebDriverWait(self.selenium, 10).until_not(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='table-content']/h4"), 'Table view'))
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'table-data_previous')))

        # Check the number of entries
        self.assertIn('Showing 1 to 10 of 100 entries',
                      self.selenium.page_source)

        # Go back to the view management
        self.selenium.find_element_by_link_text("Views").click()
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'view-table_previous')))

        # Click in the clone link of the first view
        self.selenium.find_element_by_css_selector(
            "button.btn.btn-primary.btn-sm.dropdown-toggle").click()
        self.selenium.find_element_by_css_selector(
            "button.btn.btn-default.btn-sm.js-view-clone.align-middle").click(
            )
        # Wait for the form to create the derived column
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Confirm view cloning'))

        # Confirm view cloning
        self.selenium.find_element_by_css_selector(
            "div.modal-footer > button.btn.btn-primary").click()
        self.wait_close_modal_refresh_table('view-table_previous')

        # Open the view with the clone
        self.selenium.find_element_by_css_selector(
            "span.glyphicon.glyphicon-eye-open").click()
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'table-data_previous')))

        # Check the number of entries
        self.assertIn(
            'Showing 1 to 10 of 13 entries (filtered from 100 total entries)',
            self.selenium.page_source)

        # End of session
        self.logout()
예제 #46
0
    def test_action_01_filter(self):
        # Login
        self.login('*****@*****.**')

        self.open(reverse('workflow:index'))

        # GO TO THE WORKFLOW PAGE
        WebDriverWait(self.selenium,
                      10).until(EC.title_is('OnTask :: Workflows'))
        self.assertIn('New Workflow', self.selenium.page_source)
        self.assertIn('Import Workflow', self.selenium.page_source)

        # Open the workflow
        wf_link = self.selenium.find_element_by_link_text(self.wflow_name)
        wf_link.click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'wflow-name')))

        # Goto the action page
        self.selenium.find_element_by_link_text('Actions').click()
        self.assertIn('New Action', self.selenium.page_source)

        # click in the action page
        self.selenium.find_element_by_link_text('Edit').click()
        # Wait for the action page
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.XPATH, "//div[@id='filter-set']/h4/div/button")))

        # Click in the add filter button
        self.selenium.find_element_by_xpath(
            "//div[@id='filter-set']/h4/div/button").click()
        # Wait for the form to appear
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Create action filter'))

        # Add the name and description
        self.selenium.find_element_by_id('id_name').send_keys('fname')
        self.selenium.find_element_by_id('id_description_text').send_keys(
            'fdesc')

        # Select the age filter
        sel = Select(
            self.selenium.find_element_by_name('builder_rule_0_filter'))
        sel.select_by_value('age')
        # Wait for the select elements to be clickable
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.XPATH, "//select[@name='builder_rule_0_filter']")))

        # There should only be eight operands
        filter_ops = self.selenium.find_elements_by_xpath(
            "//select[@name='builder_rule_0_operator']/option")
        self.assertEqual(len(filter_ops), 8)

        # Set the operator to less or equal
        sel = Select(
            self.selenium.find_element_by_name('builder_rule_0_operator'))
        sel.select_by_value('less_or_equal')

        # Set the value to 12.1
        self.selenium.find_element_by_name('builder_rule_0_value_0').send_keys(
            '12.1')

        # Click in the "update filter"
        self.selenium.find_element_by_xpath(
            "//div[@id='modal-item']/div/div/form/div/button[2]").click()
        # MODAL WAITING
        WebDriverWait(self.selenium, 10).until_not(
            EC.presence_of_element_located((By.CLASS_NAME, 'modal-open')))

        # Check that the filter is selecting 2 out of 3 rows
        self.assertIn('Selects 2 out of 3 rows', self.selenium.page_source)

        # Add a second clause to the filter
        # Click in the edit filter button
        self.selenium.find_element_by_class_name('js-filter-edit').click()
        # Wait for the form to modify the filter
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Edit filter'))

        # Click in the Add rule of the filter builder button
        self.selenium.find_element_by_xpath(
            "//dl[@id='builder_group_0']/dt/div/button[1]").click()
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.XPATH, "//dl[@id='builder_group_0']/dt/div/button[1]")))

        # Select the when filter
        sel = Select(
            self.selenium.find_element_by_name('builder_rule_1_filter'))
        sel.select_by_value('when')
        # Wait for the select elements to be clickable
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.XPATH, "//select[@name='builder_rule_1_operator']")))

        # There should only be eight operands
        filter_ops = self.selenium.find_elements_by_xpath(
            "//select[@name='builder_rule_1_operator']/option")
        self.assertEqual(len(filter_ops), 8)

        # Set the operator to less or equal
        sel = Select(
            self.selenium.find_element_by_name('builder_rule_1_operator'))
        sel.select_by_value('less_or_equal')

        # Set the value to 2017-10-11T00:32:44
        self.selenium.find_element_by_name('builder_rule_1_value_0').send_keys(
            '2017-10-11T00:32:44')

        # Click in the "update filter"
        self.selenium.find_element_by_xpath(
            "//div[@id='modal-item']/div/div/form/div/button[2]").click()
        # Wait for page to refresh
        # WebDriverWait(self.selenium, 10).until(
        #     EC.element_to_be_clickable(
        #         (By.CLASS_NAME, 'js-filter-edit')
        #     )
        # )
        WebDriverWait(self.selenium, 10).until_not(
            EC.presence_of_element_located((By.CLASS_NAME, 'modal-open')))

        # Check that the filter is selecting 2 out of 3 rows
        self.assertIn('Selects 1 out of 3 rows', self.selenium.page_source)

        # End of session
        self.logout()
예제 #47
0
    def test(self):
        """
        Create a workflow, upload data and merge
        :return:
        """

        question_values = 'DNA duplication, Mitosis, Kreb\'s cycle, None'

        # Login
        self.login('*****@*****.**')

        #
        # Create the workflow
        #
        self.create_new_workflow(self.workflow_name, self.description)

        # Go to CSV upload/merge
        self.selenium.find_element_by_xpath(
            "//tbody/tr[1]/td[1]/a[1]"
        ).click()
        WebDriverWait(self.selenium, 10).until(
            EC.visibility_of_element_located(
                (By.XPATH, "//form")
            )
        )

        # Set the file name
        self.selenium.find_element_by_id('id_file').send_keys(
            os.path.join(settings.BASE_DIR(),
                         '..',
                         'docs_src',
                         'Dataset',
                         'all_data.csv')
        )

        self.body_ss('tutorial_csv_upload_learner_information.png')

        # Click on the NEXT button
        self.selenium.find_element_by_xpath(
            "//button[@name='Submit']"
        ).click()
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element((By.XPATH, "//body/div/h1"),
                                             'Step 2: Select Columns')
        )

        # Uncheck two elements
        element = self.search_table_row_by_string('workflow-table',
                                                  2,
                                                  'Surname')
        element.find_element_by_xpath("td[5]/input").click()
        element = self.search_table_row_by_string('workflow-table',
                                                  2,
                                                  'GivenName')
        element.find_element_by_xpath("td[5]/input").click()

        self.body_ss('tutorial_csv_upload_confirm.png')

        # Click on the Next button
        self.selenium.find_element_by_xpath(
            "//button[@name='Submit']"
        ).click()
        self.wait_for_datatable('table-data_paginate')

        # Take picture of the table
        self.body_ss('tutorial_initial_table.png')

        # Take picture of the top-bar menu
        self.element_ss("//nav[contains(@class, 'fixed-top')]",
                        'tutorial_top_menu_bar.png')

        # Go back to details
        self.go_to_details()
        self.body_ss('tutorial_details_1.png')

        # Go back to details
        self.go_to_workflow_operations()
        self.body_ss('tutorial_workflow_operations.png')

        # Create a new view
        self.go_to_table()
        self.go_to_table_views()

        # Button to add a view
        self.selenium.find_element_by_xpath(
            "//button[normalize-space()='Add View']"
        ).click()
        # Wait for the form to create the derived column
        self.wait_for_modal_open()

        # Insert data to create the view
        element = self.selenium.find_element_by_id("id_name")
        element.click()
        element.clear()
        element.send_keys('Subset 1')
        element = self.selenium.find_element_by_id("id_description_text")
        element.click()
        element.clear()
        element.send_keys('View only student email, program and enrolment type')

        # Focus on the column area
        self.selenium.find_element_by_xpath(
            "//*[@placeholder='Click here to search']").click()
        options = self.selenium.find_element_by_xpath(
            '//*[@id="div_id_columns"]//div[@class="sol-selection"]'
        )
        for cname in ['email', 'Program', 'Enrolment Type']:
            options.find_element_by_xpath(
                'div/label/div[normalize-space()="{0}"]'.format(cname)
            ).click()

        self.selenium.find_element_by_css_selector("div.modal-header").click()

        self.modal_ss('tutorial_table_view_create.png')

        # Save the view
        self.selenium.find_element_by_xpath(
            "//button[normalize-space()='Add view']"
        ).click()
        self.wait_close_modal_refresh_table('view-table_previous')

        # Open the view
        self.open_view('Subset 1')

        # Take picture of the table
        self.body_ss('tutorial_table_view.png')

        # select the statistics of one of the learners
        element = self.search_table_row_by_string('table-data',
                                                  2,
                                                  '*****@*****.**')
        stat_page = element.find_element_by_xpath(
            "td//a[contains(@href, 'stat_row')]"
        ).get_attribute('href')
        self.selenium.get(stat_page)
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located(
                (By.XPATH,
                 "//div[@class='text-center']/a[normalize-space()='Back']")
            )
        )

        # Picture of the statistics.
        self.body_ss('tutorial_row_statistics.png')

        # Go to the actions page
        self.go_to_actions()
        self.body_ss('tutorial_action_index.png')

        # Go to the import action page
        self.selenium.find_element_by_link_text('Import action').click()
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.XPATH, "//input[@id='id_name']")
            )
        )
        self.body_ss('tutorial_action_import.png')
        self.go_to_actions()

        #
        # Merge data from Moodle
        #
        self.go_to_upload_merge()
        self.selenium.find_element_by_link_text("CSV Upload/Merge").click()
        WebDriverWait(self.selenium, 10).until(
            EC.title_is('OnTask :: Upload/Merge CSV')
        )
        self.selenium.find_element_by_id('id_file').send_keys(
            os.path.join(settings.BASE_DIR(),
                         '..',
                         'docs_src',
                         'Dataset',
                         'moodle_grades.csv')
        )

        # Picture of the body
        self.body_ss('tutorial_moodle_merge_step1.png')

        # Click the NEXT button
        self.selenium.find_element_by_xpath(
            "//button[@type='Submit']"
        ).click()
        self.wait_for_page()
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.XPATH, "//input[@id='id_make_key_2']")
            )
        )

        # Uncheck all the columns
        self.selenium.find_element_by_id('checkAll').click()

        # Check the columns to select and maintain email as unique
        for k_num in [0, 1, 2]:
            self.selenium.find_element_by_id(
                'id_upload_{0}'.format(k_num)
            ).click()
        self.selenium.find_element_by_id('id_new_name_2').clear()
        self.selenium.find_element_by_id('id_new_name_2').send_keys('email')
        # self.selenium.find_element_by_id('id_make_key_2').click()

        # Picture of the body
        self.body_ss('tutorial_moodle_merge_step2.png')

        # Click the NEXT button
        self.selenium.find_element_by_xpath("//button[@type='Submit']").click()
        self.wait_for_page()
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.XPATH, "//select[@id='id_dst_key']")
            )
        )

        # Dataops/Merge CSV Merge Step 3
        Select(self.selenium.find_element_by_id(
            'id_dst_key'
        )).select_by_value('email')
        Select(self.selenium.find_element_by_id(
            'id_src_key'
        )).select_by_value('email')
        Select(self.selenium.find_element_by_id(
            'id_how_merge'
        )).select_by_value('right')

        # Picture of the body
        self.body_ss('tutorial_moodle_merge_step3.png')

        # Click the NEXT button
        self.selenium.find_element_by_xpath(
            "//button[@type='Submit']"
        ).click()
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//body/div/h1"),
                'Step 4: Review and confirm')
        )

        # Picture of the body
        self.body_ss('tutorial_moodle_merge_step4.png')

        # Click on Finish
        self.selenium.find_element_by_xpath(
            "//button[normalize-space()='Finish']"
        ).click()
        self.wait_for_datatable('table-data_previous')

        #
        # Create PERSONALISED ACTION.
        #
        self.go_to_actions()
        self.selenium.find_element_by_class_name('js-create-action').click()
        self.wait_for_modal_open()

        # Set the name, description and type of the action
        self.selenium.find_element_by_id('id_name').send_keys('Program advice')
        desc = self.selenium.find_element_by_id('id_description_text')
        # Select the action type
        select = Select(self.selenium.find_element_by_id('id_action_type'))
        select.select_by_value(Action.PERSONALIZED_TEXT)
        desc.send_keys('')

        self.modal_ss('tutorial_personalized_text_create.png')

        desc.send_keys(Keys.RETURN)
        # Wait for the spinner to disappear, and then for the button to be
        # clickable
        WebDriverWait(self.selenium, 10).until(
            EC.visibility_of_element_located(
                (By.ID, "action-out-editor")
            )
        )
        WebDriverWait(self.selenium, 10).until_not(
            EC.visibility_of_element_located((By.ID, 'div-spinner'))
        )

        # Action editor
        self.body_ss('tutorial_personalized_text_editor.png')

        self.selenium.execute_script(
            """$('#id_content').summernote(
                   'editor.insertText', "Dear ");
               $('#summernote').summernote('editor.saveRange');""")

        select = Select(self.selenium.find_element_by_id(
            'select-column-name'))
        select.select_by_visible_text('GivenName')
        self.selenium.execute_script(
            """$('#summernote').summernote('editor.saveRange');""")

        # Take picture of the html editor
        self.element_ss("//div[@id='html-editor']",
                        'tutorial_personalized_text_editor_with_column.png')

        # Create the first condition
        self.select_condition_tab()
        self.create_condition(
            'Program is FASS',
            '',
            [('Program', 'equal', 'FASS')]
        )
        self.open_condition('Program is FASS')

        self.modal_ss('tutorial_condition_program_FASS.png')

        self.cancel_modal()

        self.select_text_tab()
        self.selenium.execute_script(
            "$('#id_content').summernote('code', '');"
            "$('#id_content').summernote("
            "'editor.insertText',"
            "'Dear {{ GivenName }}');")

        self.selenium.execute_script(
            "$('#id_content').summernote('editor.insertParagraph');")

        self.selenium.execute_script(
            "$('#id_content').summernote("
            "'editor.insertText',"
            "'{% if Program is FASS %}Here are "
            "some suggestions for FASS{% endif %}');")

        # Take picture of the html editor
        self.element_ss("//div[@id='html-editor']",
                        'tutorial_personalized_text_condition_inserted.png')

        # Create the remaining conditions
        self.select_condition_tab()
        self.create_condition('Program is FSCI',
                              '',
                              [('Program', 'equal', 'FSCI')]
                              )
        self.create_condition('Program is FEIT',
                              '',
                              [('Program', 'equal', 'FEIT')]
                              )
        self.create_condition('Program is SMED',
                              '',
                              [('Program', 'equal', 'SMED')]
                              )

        # Insert additional sentences for each program
        self.select_text_tab()
        self.selenium.execute_script(
            "$('#id_content').summernote('code', '');"
            "$('#id_content').summernote("
            "'editor.insertText',"
            "'Dear {{ GivenName }}');")
        self.selenium.execute_script(
            "$('#id_content').summernote('editor.insertParagraph');")
        self.selenium.execute_script(
            "$('#id_content').summernote("
            "'editor.insertText',"
            "'{% if Program is FASS %}Here are "
            "some suggestions for FASS{% endif %}');")
        self.selenium.execute_script(
            "$('#id_content').summernote('editor.insertParagraph');")
        self.selenium.execute_script(
            "$('#id_content').summernote("
            "'editor.insertText',"
            "'{% if Program is FSCI %}Here are "
            "some suggestions for FSCI{% endif %}');")
        self.selenium.execute_script(
            "$('#id_content').summernote('editor.insertParagraph');")
        self.selenium.execute_script(
            "$('#id_content').summernote("
            "'editor.insertText',"
            "'{% if Program is FEIT %}Here are "
            "some suggestions for FEIT{% endif %}');")
        self.selenium.execute_script(
            "$('#id_content').summernote('editor.insertParagraph');")
        self.selenium.execute_script(
            "$('#id_content').summernote("
            "'editor.insertText',"
            "'{% if Program is SMED %}Here are "
            "some suggestions for SMED{% endif %}');")
        self.selenium.execute_script(
            "$('#id_content').summernote('editor.insertParagraph');")
        self.selenium.execute_script(
            "$('#id_content').summernote('editor.insertParagraph');")
        self.selenium.execute_script(
            "$('#id_content').summernote("
            "'editor.insertText',"
            "'Kind regards');")
        self.selenium.execute_script(
            "$('#id_content').summernote('editor.insertParagraph');")
        self.selenium.execute_script(
            "$('#id_content').summernote("
            "'editor.insertText',"
            "'Jane Doe -- Course Coordinator');")

        # Take picture of the html editor
        self.element_ss("//div[@id='html-editor']",
                        'tutorial_personalized_text_condition_inserted2.png')

        # Open the filter condition
        self.select_filter_tab()
        self.create_filter('Full time attendance',
                           [('Attendance', 'equal', 'Full Time')])
        # Open it again for the picture
        self.open_filter()
        self.modal_ss('tutorial_personalized_text_filter.png')

        # Close the modal
        self.cancel_modal()

        # Action editor
        self.body_ss('tutorial_personalized_text_editor2.png')

        # Open the preview
        self.selenium.find_element_by_xpath(
            "//button[normalize-space()='Preview']"
        ).click()
        WebDriverWait(self.selenium, 10).until(
            ElementHasFullOpacity((By.XPATH, "//div[@id='modal-item']"))
        )
        self.modal_ss('tutorial_personalized_text_preview.png')

        self.cancel_modal()

        # Save action and back to action index
        self.selenium.find_element_by_xpath(
            "//button[normalize-space()='Close']"
        ).click()
        self.wait_for_datatable('action-table_previous')

        # Click in the email button
        self.open_action_run('Program advice')

        # Set the various fields in the form to send the email
        self.selenium.find_element_by_id('id_subject').send_keys(
            'Connecting your program with this course'
        )
        select = Select(self.selenium.find_element_by_id(
            'id_email_column'))
        select.select_by_value('email')
        self.selenium.find_element_by_id('id_cc_email').send_keys(
            '[email protected], [email protected]'
        )
        self.selenium.find_element_by_id('id_bcc_email').send_keys(
            '*****@*****.**'
        )
        self.selenium.find_element_by_id('id_confirm_items').click()

        # Screen shot of the body
        self.body_ss('action_personalized_text_email.png')

        # Click in the preview
        self.selenium.find_element_by_xpath(
            "//button[normalize-space()='Preview']"
        ).click()
        self.wait_for_modal_open("//div[@id='preview-body']")

        self.modal_ss('tutorial_email_preview.png')

        self.cancel_modal()

        # Click in the next button to go to the filter email screen
        self.selenium.find_element_by_xpath(
            "//button[@name='Submit']"
        ).click()
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//body/div/h1"),
                'Select items to exclude from action')
        )

        # Select two emails to exclude from the send.
        self.selenium.find_element_by_css_selector(
            "div.sol-input-container > input[type=\"text\"]"
        ).click()
        self.selenium.find_element_by_name("exclude_values").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='exclude_values'])[2]"
        ).click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='exclude_values'])[3]"
        ).click()

        self.body_ss('tutorial_exclude_action_items.png')

        # Cancel email and go back to action index
        self.selenium.find_element_by_link_text('Cancel').click()
        self.wait_for_datatable('action-table_previous')

        # Click in the URL link
        self.open_action_url('Program advice', 'URL Off')

        # Capture the modal with the URL
        self.modal_ss('tutorial_personalzed_text_URL.png')

        # Cancel the modal
        self.cancel_modal()

        #
        # Download ZIP (for Moodle)
        #
        self.open_action_zip('Program advice')

        # Select the key column
        select = Select(self.selenium.find_element_by_id(
            'id_participant_column')
        )
        select.select_by_value('Identifier')
        select = Select(self.selenium.find_element_by_id(
            'id_user_fname_column')
        )
        select.select_by_value('Full name')
        self.selenium.find_element_by_id('id_file_suffix').send_keys(
            'feedback.html'
        )
        self.selenium.find_element_by_id('id_zip_for_moodle').click()

        self.body_ss('tutorial_action_zip.png')

        # Click in the Cancel button
        self.selenium.find_element_by_link_text('Cancel').click()

        #
        # Create new personalized JSON Action
        #
        self.selenium.find_element_by_class_name('js-create-action').click()
        self.wait_for_modal_open()

        # Select the options to create a personalized JSON and then close the
        # screen
        self.selenium.find_element_by_id('id_name').send_keys(
            'Send JSON to remote server'
        )
        desc = self.selenium.find_element_by_id(
            'id_description_text'
        )
        desc.send_keys(
            'Send a JSON object to a remote server (outside this platform)'
        )
        # Select the action type
        select = Select(self.selenium.find_element_by_id('id_action_type'))
        select.select_by_value(Action.PERSONALIZED_JSON)
        desc.send_keys('')

        self.modal_ss('tutorial_personalized_json_create.png')

        desc.send_keys(Keys.RETURN)
        # Wait for the spinner to disappear, and then for the button to be
        # clickable
        # Wait for the spinner to disappear, and then for the button to be
        # clickable
        WebDriverWait(self.selenium, 10).until(
            EC.visibility_of_element_located(
                (By.ID, "action-out-editor")
            )
        )
        WebDriverWait(self.selenium, 10).until_not(
            EC.visibility_of_element_located((By.ID, 'div-spinner'))
        )

        self.create_condition('Less than 50 in the midterm',
                              '',
                              [('Total', 'less', '50')])
        self.create_condition('More or equal to 50 in midterm',
                              '',
                              [('Total', 'greater or equal', '50')])

        self.select_json_text_tab()
        self.selenium.find_element_by_id('id_content').send_keys(
            """{
  "sid": {{ SID }},
  "midterm_total": {{ Total }},
  "msg":
     {% if Less than 50 in the midterm %}"Message number 1"{% endif %}
    {% if More or equal to 50 in midterm %}"Message number 2"{% endif %}
}"""
        )

        self.selenium.find_element_by_id('id_target_url').send_keys(
            'http://127.0.0.1'
        )

        # Action editor
        self.body_ss('tutorial_personalized_json_editor.png')

        # Open the preview
        self.open_preview()
        self.modal_ss('tutorial_personalized_json_preview.png')

        self.cancel_modal()

        # Save action and back to action index
        self.selenium.find_element_by_xpath(
            "//button[normalize-space()='Close']"
        ).click()
        self.wait_for_datatable('action-table_previous')

        #
        # Click on the create action SURVEY
        #
        self.selenium.find_element_by_class_name('js-create-action').click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'id_name')))

        # Set the name, description and type of the action
        self.selenium.find_element_by_id('id_name').send_keys('Survey 1')
        desc = self.selenium.find_element_by_id('id_description_text')
        # Select the action type
        select = Select(self.selenium.find_element_by_id('id_action_type'))
        select.select_by_value(Action.SURVEY)
        desc.send_keys('Survey description for the learners')

        self.modal_ss('tutorial_survey_create.png')

        desc.send_keys(Keys.RETURN)
        # Wait for the spinner to disappear, and then for the button to be
        # clickable
        WebDriverWait(self.selenium, 10).until(
            EC.visibility_of_element_located(
                (By.XPATH, "//*[@id='action-in-editor']")
            )
        )
        WebDriverWait(self.selenium, 10).until_not(
            EC.visibility_of_element_located((By.ID, 'div-spinner'))
        )

        # Show the editor
        self.body_ss('tutorial_survey_editor.png')

        # Click on the Add Column button
        self.selenium.find_element_by_xpath(
            "//button[normalize-space()='Create question']"
        ).click()
        self.wait_for_modal_open()

        # Set the fields
        self.selenium.find_element_by_id('id_name').send_keys('Survey Q1')
        self.selenium.find_element_by_id(
            'id_description_text'
        ).send_keys(
            'What was the most challenging topic for you this week?'
        )
        select = Select(self.selenium.find_element_by_id(
            'id_data_type'))
        select.select_by_value('string')
        self.selenium.find_element_by_id(
            'id_raw_categories'
        ).send_keys(question_values)

        self.modal_ss('tutorial_survey_column_creation.png')

        # Click on the Submit button
        self.selenium.find_element_by_xpath(
            "//div[@id='modal-item']//button[normalize-space()='Add question']"
        ).click()

        self.wait_close_modal_refresh_table('column-selected-table_previous')

        # Create the second column
        self.selenium.find_element_by_xpath(
            "//button[normalize-space()='Create question']"
        ).click()
        self.wait_for_modal_open()

        # Set the fields
        self.selenium.find_element_by_id('id_name').send_keys('Survey Q2')
        self.selenium.find_element_by_id(
            'id_description_text'
        ).send_keys(
            'What was your dedication to the course this week?'
        )
        select = Select(self.selenium.find_element_by_id(
            'id_data_type'))
        select.select_by_value('string')
        self.selenium.find_element_by_id(
            'id_raw_categories'
        ).send_keys(
            'less than 2 hours',
            'between 2 and 4 hours',
            'between 4 and 6 hours',
            'more than 6 hours'
        )

        # Click on the Submit button
        self.selenium.find_element_by_xpath(
            "//div[@id='modal-item']//button[normalize-space()='Add question']"
        ).click()

        self.wait_close_modal_refresh_table('column-selected-table_previous')

        # Click in the key-select
        self.select_parameters_tab()

        # Select email column as key column
        select = Select(self.selenium.find_element_by_id(
            'select-key-column-name'))
        select.select_by_visible_text('email')
        # Table disappears (page is updating) -- Wait for spinner, and then
        # refresh
        WebDriverWait(self.selenium, 10).until_not(
            EC.visibility_of_element_located((By.ID, 'div-spinner'))
        )

        # Show the editor
        self.body_ss('tutorial_survey_editor2.png')

        # Click the preview button
        self.open_preview()
        self.modal_ss('tutorial_survey_preview.png')

        self.cancel_modal()

        # Save action and back to action index
        self.selenium.find_element_by_link_text('Done').click()
        self.wait_for_datatable('action-table_previous')

        #
        # Create an new action combining existing data with survey ata
        #
        self.create_new_personalized_text_action('More Strategies', '')

        # Create the conditions for those that failed the exam
        self.select_condition_tab()
        topics = [x.strip() for x in question_values.split(',')]
        for topic in topics:
            self.create_condition(
                topic[0:4] + ' - Fail',
                '',
                [('Survey Q1', 'equal', topic),
                 ('Total', 'less', 50)]
            )
        # Create the conditions for those that passed the exam
        for topic in topics:
            self.create_condition(
                topic[0:4] + ' - Passed',
                '',
                [('Survey Q1', 'equal', topic),
                 ('Total', 'greater or equal', 50)]
            )

        # Action editor
        self.select_text_tab()
        self.selenium.execute_script(
            """$('#id_content').summernote(
                   'editor.insertText', "Dear {{ GivenName }}");""")
        self.selenium.execute_script(
            "$('#id_content').summernote('editor.insertParagraph');")
        self.selenium.execute_script(
            """$('#id_content').summernote(
                   'editor.insertText', "Here are some suggestions.");""")
        self.selenium.execute_script(
            "$('#id_content').summernote('editor.insertParagraph');")

        # Add the text for those that failed
        for topic in topics:
            self.selenium.execute_script(
                ("""$("#id_content").summernote("editor.insertText",""" 
                 """ "{{% if {0} - Fail %}}Tips about {0} """ 
                 """for those that failed.{{% endif %}}");""").format(topic))
            self.selenium.execute_script(
                "$('#id_content').summernote('editor.insertParagraph');")

        # Add the text for those that passed
        for topic in topics:
            self.selenium.execute_script(
                ("""$('#id_content').summernote("editor.insertText",""" 
                 """ "{{% if {0} - Passed %}}Tips about {0} """ 
                 """for those that passed.{{% endif %}}");""").format(topic))
            self.selenium.execute_script(
                "$('#id_content').summernote('editor.insertParagraph');")

        self.selenium.execute_script(
            """$('#id_content').summernote(
                   'editor.insertText', "Kind regards -- Jane Doe");""")

        # Create the filter
        self.select_filter_tab()
        self.create_filter('Complete data',
                           [('Survey Q1', 'is not null', None),
                            ('Total', 'is not null', None)])

        # Open to take the picture
        self.open_filter()
        self.modal_ss('tutorial_personalized_text_and_survey_filter.png')
        self.cancel_modal()

        # Action editor
        self.select_text_tab()
        self.body_ss('tutorial_personalized_text_and_survey.png')

        # Save action and back to action index
        self.selenium.find_element_by_xpath(
            "//button[normalize-space()='Close']"
        ).click()
        self.wait_for_datatable('action-table_previous')

        # End of session
        self.logout()

        # Close the db_engine
        pandas_db.destroy_db_engine(pandas_db.engine)
예제 #48
0
    def test_action_04_save_action_with_buttons(self):
        # Login
        self.login('*****@*****.**')

        self.open(reverse('workflow:index'))

        # GO TO THE WORKFLOW PAGE
        WebDriverWait(self.selenium,
                      10).until(EC.title_is('OnTask :: Workflows'))
        self.assertIn('New Workflow', self.selenium.page_source)
        self.assertIn('Import Workflow', self.selenium.page_source)

        # Open the workflow
        wf_link = self.selenium.find_element_by_link_text(self.wflow_name)
        wf_link.click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'wflow-name')))

        # Goto the action page
        self.selenium.find_element_by_link_text('Actions').click()
        self.assertIn('New Action', self.selenium.page_source)

        # click in the action page
        self.selenium.find_element_by_link_text('Edit').click()
        # Wait for the action page
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.XPATH, "//div[@id='filter-set']/h4/div/button")))

        # Make sure the content has the correct text
        self.assertEqual(
            "{% comment %}Your action content here{% endcomment %}",
            self.selenium.execute_script(
                """return $("#id_content").summernote('code')"""))

        # insert the first mark
        self.selenium.execute_script(
            """$('#id_content').summernote('editor.insertText', "mark1");""")

        # Create filter. Click in the add filter button
        self.selenium.find_element_by_xpath(
            "//div[@id='filter-set']/h4/div/button").click()
        # Wait for the form to appear
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Create action filter'))

        # Add the name and description
        self.selenium.find_element_by_id('id_name').send_keys('fname')
        self.selenium.find_element_by_id('id_description_text').send_keys(
            'fdesc')

        # Select the age filter
        sel = Select(
            self.selenium.find_element_by_name('builder_rule_0_filter'))
        sel.select_by_value('age')
        # Wait for the select elements to be clickable
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.XPATH, "//select[@name='builder_rule_0_filter']")))

        # Set the operator to less or equal
        sel = Select(
            self.selenium.find_element_by_name('builder_rule_0_operator'))
        sel.select_by_value('less_or_equal')

        # Set the value to 12.1
        self.selenium.find_element_by_name('builder_rule_0_value_0').send_keys(
            '12.1')

        # Click in the "update filter"
        self.selenium.find_element_by_xpath(
            "//div[@id='modal-item']/div/div/form/div/button[2]").click()
        # Wait for page to refresh (FLAKY)
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable((By.CLASS_NAME, 'js-filter-edit')))

        # Make sure the content has the correct text
        self.assertIn(
            "mark1",
            self.selenium.execute_script(
                """return $("#id_content").summernote('code')"""))

        # insert the second mark
        self.selenium.execute_script(
            """$('#id_content').summernote('editor.insertText', "mark2");""")

        # Modify the filter. Click in the edit filter button
        self.selenium.find_element_by_class_name('js-filter-edit').click()
        # Wait for the form to modify the filter
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Edit filter'))

        # Modify its name
        self.selenium.find_element_by_id('id_name').send_keys('2')

        # Click in the "update filter"
        self.selenium.find_element_by_xpath(
            "//div[@id='modal-item']/div/div/form/div/button[2]").click()
        # Wait for page to refresh (FLAKY)
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable((By.CLASS_NAME, 'js-filter-edit')))

        # Make sure the content has the correct text
        self.assertIn(
            "mark2",
            self.selenium.execute_script(
                """return $("#id_content").summernote('code')"""))

        # insert the third mark
        self.selenium.execute_script(
            """$('#id_content').summernote('editor.insertText', "mark3");""")

        # Click in the more ops and then the delete filter button
        self.selenium.find_element_by_xpath(
            "//div[@id='filter-set']/h4/div/button[2]").click()
        self.selenium.find_element_by_class_name('js-filter-delete').click()
        # Wait for the screen to delete the filter
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Confirm filter deletion'))

        # Click in the "delete filter"
        self.selenium.find_element_by_xpath(
            "//div[@id='modal-item']/div/div/form/div/button[2]").click()
        # MODAL WAITING
        WebDriverWait(self.selenium, 10).until_not(
            EC.presence_of_element_located((By.CLASS_NAME, 'modal-open')))

        # Make sure the content has the correct text
        self.assertIn(
            "mark3",
            self.selenium.execute_script(
                """return $("#id_content").summernote('code')"""))
        # insert the first mark
        self.selenium.execute_script(
            """$('#id_content').summernote('editor.insertText', "cmark1");""")

        # Create condition. Click in the add condition button
        self.selenium.find_element_by_xpath(
            "//div[@id='condition-set']/h4/button").click()
        # Wait for the form to appear
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Create condition'))

        # Add the name and description
        self.selenium.find_element_by_id('id_name').send_keys('fname')
        self.selenium.find_element_by_id('id_description_text').send_keys(
            'fdesc')

        # Select the age filter
        sel = Select(
            self.selenium.find_element_by_name('builder_rule_0_filter'))
        sel.select_by_value('age')
        # Wait for the select elements to be clickable
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.XPATH, "//select[@name='builder_rule_0_filter']")))

        # Set the operator to less or equal
        sel = Select(
            self.selenium.find_element_by_name('builder_rule_0_operator'))
        sel.select_by_value('less_or_equal')

        # Set the value to 12.1
        self.selenium.find_element_by_name('builder_rule_0_value_0').send_keys(
            '12.1')

        # Click in the "create condition"
        self.selenium.find_element_by_xpath(
            "//div[@id='modal-item']/div/div/form/div/button[2]").click()
        # Wait for page to refresh (FLAKY)
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable((By.CLASS_NAME, 'js-condition-edit')))

        # Make sure the content has the correct text
        self.assertIn(
            "cmark1",
            self.selenium.execute_script(
                """return $("#id_content").summernote('code')"""))

        # insert the second mark
        self.selenium.execute_script(
            """$('#id_content').summernote('editor.insertText', "cmark2");""")

        # Modify the filter. Click in the edit filter button
        self.selenium.find_element_by_class_name('js-condition-edit').click()
        # Wait for the form to modify the filter
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Edit condition'))

        # Modify its name
        self.selenium.find_element_by_id('id_name').send_keys('2')

        # Click in the "update condition"
        self.selenium.find_element_by_xpath(
            "//div[@id='modal-item']/div/div/form/div/button[2]").click()
        # Wait for page to refresh
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable((By.CLASS_NAME, 'js-condition-edit')))

        # Make sure the content has the correct text
        self.assertIn(
            "cmark2",
            self.selenium.execute_script(
                """return $("#id_content").summernote('code')"""))

        # insert the third mark
        self.selenium.execute_script(
            """$('#id_content').summernote('editor.insertText', "cmark3");""")

        # Click in the delete condition button
        self.selenium.find_element_by_xpath(
            "//div[@id='condition-set']/div/div/button[2]").click()
        self.selenium.find_element_by_class_name('js-condition-delete').click()
        # Wait for the screen to delete the condition
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Confirm condition deletion'))

        # Click in the "delete condition"
        self.selenium.find_element_by_xpath(
            "//div[@id='modal-item']/div/div/form/div/button[2]").click()
        # MODAL WAITING
        WebDriverWait(self.selenium, 10).until_not(
            EC.presence_of_element_located((By.CLASS_NAME, 'modal-open')))

        # Make sure the content has the correct text
        self.assertIn(
            "cmark3",
            self.selenium.execute_script(
                """return $("#id_content").summernote('code')"""))

        # End of session
        self.logout()
예제 #49
0
from selenium import webdriver
#控制浏览器
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver=webdriver.Firefox()
driver.get("https://www.baidu.com")
#driver.find_element_by_css_selector("/html/body/div[1]/div[1]/div/div[3]/a[1]").click()
driver.find_element_by_xpath("//*[@id='kw']").send_keys("测试")
driver.find_element_by_xpath("//*[@id='su']").click()
#返回true
element=WebDriverWait(driver,5,0.5).until(EC.title_is("测试_百度搜索"))
print(element)
#find_elements_by_id() 定位一组元素

예제 #50
0
# EC是 expected_conditions的别名
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome()
driver.get('https://www.baidu.com')
res = EC.title_is('百度一下,你就知道')(driver)
assert res == True
res = EC.title_contains('百度一')(driver)
print(res)
예제 #51
0
    chrome_options = Options()
    chrome_options.add_argument('--headless')
    chrome_options.add_argument('--no-sandbox')
    chrome_options.add_argument('--disable-dev-shm-usage')
    myChrome = webdriver.Chrome('./chromedriver.exe',chrome_options=option)
    myChrome.get('https://pc.xuexi.cn/points/login.html')
    myChrome.execute_script("var q=document.documentElement.scrollTop=950")
    myChrome.execute_script("var q=document.documentElement.scrollLeft=225")
    time.sleep(3)
    nowTime = time.strftime('%m-%d_', time.localtime(time.time()))
    myChrome.save_screenshot(path + nowTime + '扫码登陆.png')
    print(path + nowTime + '扫码登陆.png')
    time.sleep(15)

    try:
        WebDriverWait(myChrome, 60).until(EC.title_is(u"我的学习"))
        print('登录成功')
    except:
        myChrome.find_elements_by_xpath("//span[@class='refresh']")[0].click()
        time.sleep(1.5)
        nowTime = time.strftime('%m-%d_', time.localtime(time.time()))
        myChrome.save_screenshot(path + nowTime + '扫码登陆.png')
        print('登录超时,脚本退出')
        exit()
    # 进入首页
    myChrome.get("https://www.xuexi.cn/")
    myChrome.implicitly_wait(10)
    get_integralsTemp()  # 获得当前积分
    read_articles(3)  # 阅读文章 2*3
    get_integralsTemp()  # 获得当前积分
    watch_videos(2)  # 观看视频 3*2
예제 #52
0
 def is_title(self, title, timeout=10):
     '''判断title完全等于'''
     result = WebDriverWait(self.webdriver, timeout, 1).until(EC.title_is(title))
     return result   
예제 #53
0
#coding:utf-8
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome()
driver.get("http://www.cnblogs.com/101718qiong/")

title = EC.title_is(u"Silence&QH - 博客园")
print(title)

print(title(driver))
예제 #54
0
    def sign_out(self):
        element = self.driver.find_element_by_partial_link_text('Log out')
        element.click()

        WebDriverWait(self.driver, 10).until(
            expected_conditions.title_is('URLTeam Tracker'))
예제 #55
0
        for (_name, _down_link) in zip(img.name, img.down_link):
            if _name not in os.listdir(image_keep_path):
                print(_name + '   ' + _down_link, end='\n')
                download_image_list(_down_link)


if __name__ == '__main__':
    bili_imgs = []
    chrome = webdriver.Chrome(chrome_path)
    chrome.set_window_position(100, 50)
    chrome.set_window_size(1300, 1000)

    # 插画 最热
    chrome.get(illustration_hot)
    time.sleep(3)
    WebDriverWait(chrome, 10).until(EC.title_is('插画_画友_哔哩哔哩相簿'))
    # page_down(chrome,30)
    time.sleep(3)
    bili_imgs = get_bili_img()

    # download_first_page_image(bili_imgs)

    for i in range(0, len(bili_imgs), step):
        tmp_imgs = bili_imgs[i:i + step]
        for img in tmp_imgs:
            js = "window.open(\"{0}\")".format(img.detail_link)
            chrome.execute_script(js)
        time.sleep(3)
        handles = chrome.window_handles

        for (handle, img) in zip(handles[-1:-len(handles):-1], tmp_imgs):
예제 #56
0
def wait_for_page(d, title, time=30):
    """
    Uses webdriver(d) to wait for page title(title) to become visible
    """
    WebDriverWait(d, time).until(ec.title_is(title))
예제 #57
0
def testShouldBeAbleToClickInAFrameThatRewritesTopWindowLocation(driver, pages):
    pages.load("click_tests/issue5237.html")
    driver.switch_to.frame(driver.find_element_by_id("search"))
    driver.find_element(By.ID, "submit").click()
    driver.switch_to.default_content()
    WebDriverWait(driver, 3).until(EC.title_is("Target page for issue 5237"))
예제 #58
0
 def is_title(self, title, timeout=10):
     result = WebDriverWait(self.driver, timeout,
                            1).until(EC.title_is(title))
     return result
예제 #59
0
while not isComplete:
    try:
        add_to_cart_button = WebDriverWait(driver, 10).until(
            EC.element_to_be_clickable((By.CLASS_NAME, "addToCartButton")))
    except:
        driver.refresh()
        continue

    print("Add to cart button found")

    try:
        add_to_cart_button.click()

        title_change = WebDriverWait(driver, 10).until(
            EC.title_is("Best Buy Canada | Best Buy Canada"))

        driver.get("https://www.bestbuy.ca/en-ca/basket")

        con_to_checkout = WebDriverWait(driver, 10).until(
            EC.presence_of_element_located((
                By.XPATH,
                "/html/body/div[1]/div/div[4]/div[2]/div[2]/section/div/section/section[2]/div[2]"
            )))

        con_to_checkout.click()

        username = WebDriverWait(driver, 10).until(
            EC.presence_of_element_located((By.ID, "username")))

        username.send_keys(cred.bestBuyEmail)
def test_login_admin(driver):
    driver.get("http://localhost/litecart/admin/")
    driver.find_element_by_name("username").send_keys("admin")
    driver.find_element_by_name("password").send_keys("admin")
    driver.find_element_by_name("login").click()
    WebDriverWait(driver, 5).until(EC.title_is("My Store"))