当前位置: 首页>>代码示例>>Python>>正文


Python WebDriverWait.accept方法代码示例

本文整理汇总了Python中selenium.webdriver.support.ui.WebDriverWait.accept方法的典型用法代码示例。如果您正苦于以下问题:Python WebDriverWait.accept方法的具体用法?Python WebDriverWait.accept怎么用?Python WebDriverWait.accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在selenium.webdriver.support.ui.WebDriverWait的用法示例。


在下文中一共展示了WebDriverWait.accept方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delCourseContents

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import accept [as 别名]
def delCourseContents(d):
    print "Deleting From Course"
    d.find_element_by_xpath("//th[text()[contains(.,'/courses')]]/span/a").click()
    d.find_element_by_partial_link_text("Open").click()
    WebDriverWait(d, MAX_WAIT).until(EC.presence_of_element_located((By.ID, "listContainer_selectAll"))).click()
    d.find_element_by_xpath("//label[text()[contains(.,'Recycle Bin')]]").click()
    print "Unselected recycle bin"
    d.find_element_by_partial_link_text("Delete").click()
    deleteAlert = WebDriverWait(d, MAX_WAIT).until(EC.alert_is_present())
    deleteAlert = tester.driver.switch_to.alert
    if deleteAlert:
        deleteAlert.accept()
    print "Pressed delete, this could take up to 10 minutes"
    # Super long delay
    try:
        WebDriverWait(d, 600).until(EC.presence_of_element_located((By.ID, "badMmsg1")))
        error = d.find_element_by_id("badMsg1").text
        print "Deleting from course: " + error
        if str(error).contains("Failure deleting content."):
            d.find_element_by_partial_link_text("Recycle Bin").click()
            print "Recursing into the recycle bin"
            delCourseContents(d)
    except:
        traceback.print_exc()
    print "Done deleting from course"
    return
开发者ID:hattenator,项目名称:blackboard-selenium-python,代码行数:28,代码来源:testModule.py

示例2: test_it

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import accept [as 别名]
 def test_it(self):
     browser.get(self.login_url)
     self.assertEqual(browser.title, 'Auth Page')
     browser.find_element_by_id('openid').submit()
     login = WebDriverWait(browser, 2).until(
         EC.presence_of_element_located((By.NAME, 'user_name')))
     self.assertEqual(browser.title, 'Sign In')
     login.send_keys(self.login)
     passwd = browser.find_element_by_name('password')
     passwd.send_keys(self.password)
     passwd.submit()
     find_alert = EC.alert_is_present()
     find_continue = EC.presence_of_element_located(
         (By.ID, 'continue-button'))
     result = WebDriverWait(browser, 2).until(
         lambda driver: find_alert(driver) or find_continue(driver))
     if isinstance(result, Alert):
         alert = browser.switch_to_alert()
     else:
         result.click()
         alert = WebDriverWait(browser, 2).until(EC.alert_is_present())
     alert.accept()
     result = WebDriverWait(browser, 2).until(
         EC.presence_of_element_located((By.ID, 'result')))
     self.assertEqual(browser.title, 'Result Page')
     result = json.loads(result.text)
     self.assertTrue('profile' in result)
     self.assertTrue('credentials' in result)
     profile = result['profile']
     self.assertTrue('name' in profile)
     self.assertTrue('accounts' in profile)
开发者ID:dobrite,项目名称:velruse,代码行数:33,代码来源:tests.py

示例3: test_compare_products_removal_alert

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import accept [as 别名]
    def test_compare_products_removal_alert(self):
        # 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("phones")
        search_field.submit()

        # click the Add to compare link
        self.driver.\
            find_element_by_link_text("Add to Compare").click()

        # wait for Clear All link to be visible
        clear_all_link = WebDriverWait(self.driver, 10)\
            .until(expected_conditions.visibility_of_element_located((By.LINK_TEXT, "Clear All")))

        # click on Clear All link,
        # this will display an alert to the user
        clear_all_link.click()

        # wait for the alert to present
        alert = WebDriverWait(self.driver, 10)\
            .until(expected_conditions.alert_is_present())

        # get the text from alert
        alert_text = alert.text

        # check alert text
        self.assertEqual("Are you sure you would like to remove all products from your comparison?",
                          alert_text)
        # click on Ok button
        alert.accept()
开发者ID:jallman112,项目名称:learnsewithpython,代码行数:35,代码来源:comparetests.py

示例4: test_js_alert

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import accept [as 别名]
    def test_js_alert(self):
        # click the JavaScript Alerts to open test-page
        self.driver.find_element_by_link_text('JavaScript Alerts').click()

        # wait for Alert Button to be visible
        confirm_button = WebDriverWait(self.driver, 10)\
            .until(expected_conditions.visibility_of_element_located(
                (By.XPATH, "//li/button[text()='Click for JS Confirm']")))

        # click on Alert Button,
        # this will display an alert to the user
        confirm_button.click()

        # wait for the alert to present
        alert = WebDriverWait(self.driver, 10)\
            .until(expected_conditions.alert_is_present())

        # get the text from alert
        alert_text = alert.text

        # check alert text
        self.assertEqual('I am a JS Confirm', alert_text)
        # click on Ok button
        alert.accept()
开发者ID:boldirev77,项目名称:selenium_tests,代码行数:26,代码来源:ch_5_alerts.py

示例5: deleteCourseUploads

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import accept [as 别名]
def deleteCourseUploads(tester, debug=True):
    sysadmin(tester)
    d = tester.driver
    d.switch_to.default_content()
    d.switch_to.frame("contentFrame")
    d.find_element_by_partial_link_text("Manage Content").click()
    d.switch_to.default_content()
    d.switch_to.frame("contentFrame")
    d.switch_to.frame("WFS_Navigation")
    WebDriverWait(d, MAX_WAIT).until(EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, "Tools"))).click()
    WebDriverWait(d, MAX_WAIT).until(EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, "Go to Location"))).click()
    d.switch_to.default_content()
    d.switch_to.frame("contentFrame")
    d.switch_to.frame("WFS_Files")
    Location = WebDriverWait(d, MAX_WAIT).until(EC.presence_of_element_located((By.ID, "entryURL_CSFile")))
    Location.click()
    Location.clear()
    Location.send_keys("/internal/courses/")
    d.find_element_by_xpath("//input[@name='top_Submit']").click()
    if debug:
        printTitle(d)
        print "Searching to /internal/courses"
    WebDriverWait(d, 30).until(EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, "Edit Paging"))).click()
    IPP = d.find_element_by_xpath("//input[@id='listContainer_numResults']")
    IPP.clear()
    IPP.send_keys("2000")
    Go = d.find_element_by_xpath("//a[@id='listContainer_gopaging']")
    Go.click()
    sortedDesc = False
    while sortedDesc is False:
        size = WebDriverWait(d, 10).until(EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, "Size")))
        try:
            d.find_element_by_xpath("//span[@sortdir='down']")
            sortedDesc = True
            break
        except:
            size.click()
            time.sleep(2)

    irFile = open(tester.course_id_dump, "r")
    existingCourses = {}
    for row in irFile:
        c = row.lstrip().rstrip()
        existingCourses[c] = True
    if len(existingCourses) < 10:
        print "Problem with list of courses"
        return False
    if debug:
        print "Sample course ID: '" + list(existingCourses)[5] + "'"

    while True:
        WebDriverWait(d, 300).until(EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, "Edit Paging")))
        time.sleep(2)
        d.find_element_by_id("listContainer_selectAll").click()
        time.sleep(4)
        rows = d.find_element_by_id("listContainer_databody").find_elements_by_tag_name("TR")
        clicked = len(rows)
        print "Found " + str(len(rows)) + " rows"
        for row in rows:
            courseHREF = row.find_element_by_tag_name("th").find_element_by_tag_name("a")
            if courseHREF and courseHREF.text:
                if "20" in courseHREF.text:
                    courseName = courseHREF.text.lstrip().rstrip()
                    if debug:
                        print "Searching for course '" + courseName + "'"
                    if courseName not in existingCourses:
                        if debug:
                            print "Checking course '" + courseName + "'"
                        continue
                if debug:
                    print "Unchecking course '" + courseName + "'"
                row.find_element_by_tag_name("input").click()
                clicked -= 1

        print "Will delete " + str(clicked) + " courses"
        d.find_element_by_partial_link_text("Delete").click()
        retries = 0
        while retries < 3:
            try:
                try:
                    deleteAlert = WebDriverWait(d, MAX_WAIT).until(EC.alert_is_present())
                except:
                    pass
                deleteAlert = d.switch_to.alert
                if deleteAlert:
                    time.sleep(3)  # give me time to verify the alert is there
                    deleteAlert.accept()
                    break
            except Exception as e:
                print "Failed at alerts"
                traceback.print_exc()
                retries += 1
                time.sleep(3)

        if clicked == 0:
            print "Done"
            return True
        time.sleep(30)
        WebDriverWait(d, 600).until(readystate_complete)
        print "Deleted " + str(clicked) + " courses"
#.........这里部分代码省略.........
开发者ID:hattenator,项目名称:blackboard-selenium-python,代码行数:103,代码来源:testModule.py

示例6: deleteOrphanedContent

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import accept [as 别名]
def deleteOrphanedContent(tester, debug=True):
    sysadmin(tester)
    d = tester.driver
    d.switch_to.default_content()
    d.switch_to.frame("contentFrame")
    d.find_element_by_partial_link_text("Administrator Search").click()
    d.switch_to.default_content()
    d.switch_to.frame("contentFrame")
    WebDriverWait(tester.driver, MAX_WAIT).until(
        EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, "Content Orphaned by Location"))
    ).click()
    d.switch_to.default_content()
    d.switch_to.frame("contentFrame")
    if debug:
        printTitle(d)
        print "About to edit paging"
    WebDriverWait(tester.driver, 300).until(
        EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, "Edit Paging"))
    ).click()
    #    PageButton=d.find_element_by_xpath("//a[text()[contains(.,'Edit Paging')]]")
    #    PageButton.click()
    IPP = d.find_element_by_xpath("//input[@id='listContainer_numResults']")
    IPP.clear()
    IPP.send_keys("1000")
    Go = d.find_element_by_xpath("//a[@id='listContainer_gopaging']")
    Go.click()
    for x in range(0, 10):
        d.switch_to.default_content()
        d.switch_to.frame("contentFrame")
        if debug:
            printTitle(d)
            print "Edited paging, waiting for selectAll"
        WebDriverWait(tester.driver, 600).until(
            EC.presence_of_element_located((By.ID, "listContainer_selectAll"))
        ).click()
        error = None
        try:
            error = d.find_element_by_id("badMsg1").text
            print error
        except:
            pass
        try:
            if error and "Failure deleting content." in error:
                delCourseContents(d)
        except:
            traceback.print_exc()
        time.sleep(SHORT_WAIT)
        try:
            rows = d.find_element_by_id("listContainer_databody").find_elements_by_tag_name("TR")
            print str(len(rows)) + " rows"
        except Exception as e:
            print "Failed at counting"
            traceback.print_exc()
        time.sleep(SHORT_WAIT)
        if debug:
            printTitle(d)
            print "Select All Found"
        try:
            d.find_element_by_id("listContainer_row:0")
        except:
            print "Done"
            return False
        d.find_element_by_partial_link_text("Delete").click()
        if debug:
            print "Clicked Delete"
        time.sleep(SHORT_WAIT)
        deleteAlert = None
        try:
            deleteAlert = WebDriverWait(d, MAX_WAIT).until(EC.alert_is_present())
            deleteAlert = tester.driver.switch_to.alert
            if deleteAlert:
                deleteAlert.accept()

        except Exception as e:
            # print "Failed at alerts"
            # traceback.print_exc()
            pass
        print "Deleted 1000 courses"
    return True
开发者ID:hattenator,项目名称:blackboard-selenium-python,代码行数:81,代码来源:testModule.py


注:本文中的selenium.webdriver.support.ui.WebDriverWait.accept方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。