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


Python expected_conditions.alert_is_present方法代码示例

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


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

示例1: bt_btc_withdraw

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import alert_is_present [as 别名]
def bt_btc_withdraw(amount):
    browser.get('http://btc38.com/trade_en.html')
    WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.XPATH, '//*[@id="header_login_text"]/a')))
    login = browser.find_element_by_xpath('//*[@id="header_login_text"]/a')
    login.click()
    browser.get('http://www.btc38.com/trade/trade_setaddr_en.html?coinname=btc')
    WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.XPATH, '//*[@id="drawBalance"]')))
    WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.XPATH, '//*[@id="submitDrawBTN"]/a')))
    time.sleep(2)
    btc_amount = browser.find_element_by_xpath('//*[@id="drawBalance"]')     # Make sure poloniex address is on the top
    btc_amount.send_keys(str(amount))
    btc_submit = browser.find_element_by_xpath('//*[@id="submitDrawBTN"]/a')
    btc_submit.click()
    WebDriverWait(browser, 10).until(EC.alert_is_present())
    time.sleep(1)
    alert = browser.switch_to.alert
    time.sleep(1)
    alert.accept() 
开发者ID:clayop,项目名称:jebi,代码行数:20,代码来源:jebi.py

示例2: bt_bts_withdraw

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import alert_is_present [as 别名]
def bt_bts_withdraw(amount):
    browser.get('http://btc38.com/trade_en.html')
    WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.XPATH, '//*[@id="header_login_text"]/a')))
    login = browser.find_element_by_xpath('//*[@id="header_login_text"]/a')
    login.click()
    browser.get('http://www.btc38.com/trade/trade_setaddr_en.html?coinname=bts')
    WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.XPATH, '//*[@id="drawBalance"]')))
    WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.XPATH, '//*[@id="memo"]')))
    WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.XPATH, '//*[@id="submitDrawBTN"]/a')))
    time.sleep(2)
    bts_amount = browser.find_element_by_xpath('//*[@id="drawBalance"]')     # Make sure the Poloniex is on the top
    bts_amount.send_keys(str(amount))
    bts_memo = browser.find_element_by_xpath('//*[@id="memo"]')
    bts_memo.send_keys(config_jebi.polo_bts_memo)
    bts_submit = browser.find_element_by_xpath('//*[@id="submitDrawBTN"]/a')
    bts_submit.click()
    WebDriverWait(browser, 10).until(EC.alert_is_present())
    time.sleep(1)
    alert = browser.switch_to.alert
    time.sleep(1)
    alert.accept() 
开发者ID:clayop,项目名称:jebi,代码行数:23,代码来源:jebi.py

示例3: testGETXSSDriver

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import alert_is_present [as 别名]
def testGETXSSDriver(url: str, cookies: Mapping[str, str], driver: webdriver) -> Optional[str]:
    """ If the given URL pops an alert box when accessed with the given cookies, return the contents of the alert box,
        otherwise return None """
    driver.setCookies(url, cookies)

    try:
        driver.get(url)

        WebDriverWait(driver, config.timeout).until(expected_conditions.alert_is_present())
        # Note that despite the name switch_to_alert also handles prompt:
        #   - http://selenium-python.readthedocs.io/navigating.html#popup-dialogs
        alert = driver.switch_to_alert()
        text = alert.text
        driver.reset()
        return text
    except (TimeoutException, URLError):
        driver.reset()
        return None 
开发者ID:salesforce,项目名称:AutoTriageBot,代码行数:20,代码来源:xss.py

示例4: testPOSTXSSDriver

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import alert_is_present [as 别名]
def testPOSTXSSDriver(url: str, cookies: Mapping[str, str], data: Mapping[str, str], driver: webdriver) -> \
        Optional[str]:
    """ If the given URL pops an alert box when accessed with the given cookies, return the contents of the alert box,
        otherwise return None """
    driver.setCookies(url, cookies)

    try:
        driver.post(url, data)

        WebDriverWait(driver, config.timeout).until(expected_conditions.alert_is_present())
        # Note that despite the name switch_to_alert also handles prompt:
        #   - http://selenium-python.readthedocs.io/navigating.html#popup-dialogs
        alert = driver.switch_to_alert()
        text = alert.text
        driver.reset()
        return text
    except (TimeoutException, URLError):
        driver.reset()
        return None 
开发者ID:salesforce,项目名称:AutoTriageBot,代码行数:21,代码来源:xss.py

示例5: query_scanner

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import alert_is_present [as 别名]
def query_scanner(self, payload):
        for param in self.params.keys():
            previous_value = self.params[param]
            self.params[param] = payload
            target_url = encode_url(self.base_url, self.params)
            self.raw_params = urllib.parse.urlencode(self.params)
            if self.cookies: 
                self.driver.get(self.url)
                self.driver.add_cookie(self.cookies)
            self.driver.get(target_url)
            try:
                WebDriverWait(self.driver, 1).until(expected_conditions.alert_is_present())
                self.driver.switch_to.alert.accept()
                if self.count_results(self.raw_params, target_url, "URL Query"):
                    self.driver.quit()
                    self.final_report()
            except TimeoutException:
                pass 
开发者ID:M4cs,项目名称:traxss,代码行数:20,代码来源:scanner.py

示例6: html_scanner

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import alert_is_present [as 别名]
def html_scanner(self, payload, webelement_list, target_url):
        for id in webelement_list:
            try:
                if id.tag_name == 'textarea' or id.tag_name == 'input':
                    id.send_keys(payload)
                    WebDriverWait(self.driver, 1).until(expected_conditions.alert_is_present())
                    self.driver.switch_to.alert.accept()
                    if self.count_results(self.raw_params, target_url, "HTML Injection"):
                        self.driver.quit()
                        self.final_report()
                if id.tag_name == 'button' or id.tag_name == 'input':
                    id.click()
                    WebDriverWait(self.driver, 1).until(expected_conditions.alert_is_present())
                    self.driver.switch_to.alert.accept()
                    if self.count_results(self.raw_params, target_url, "HTML Injection"):
                        self.driver.quit()
                        self.final_report()
            except TimeoutException:
                pass
            except StaleElementReferenceException:
                pass
            except ElementNotInteractableException:
                pass 
开发者ID:M4cs,项目名称:traxss,代码行数:25,代码来源:scanner.py

示例7: CloseAlert

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import alert_is_present [as 别名]
def CloseAlert(self):
        '''
        Method to close an alert
        '''
        try:
            aviso = self.wait
            aviso.until(EC.alert_is_present())

            alert = self.driver.switch_to.alert
            alert.accept()
        except TimeoutException:
            time.sleep(0.5) 
开发者ID:totvs,项目名称:tir,代码行数:14,代码来源:apw_internal.py

示例8: accept_alert

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import alert_is_present [as 别名]
def accept_alert(self, expected_text, timeout=1):
        self.wait_until(ec.alert_is_present(), timeout)
        alert = self.selenium.switch_to_alert()
        self.assertEqual(alert.text, expected_text)
        alert.accept() 
开发者ID:aaugustin,项目名称:django-userlog,代码行数:7,代码来源:tests.py

示例9: test03ForgotPasswordInvalid

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import alert_is_present [as 别名]
def test03ForgotPasswordInvalid(self):
        self.browser.get('http://'+self.URL)
        self.browser.find_element_by_link_text('forgot password?').click()
        WebDriverWait(self.browser, 5).until(EC.title_is('anvio forgot password'))
        self.browser.find_element_by_id('inputEmail').send_keys('invalid@email.com')
        self.browser.find_element_by_id('submit').click()
        WebDriverWait(self.browser, 5).until(EC.alert_is_present())
        self.assertEqual('Resetting password failed: No user has been found for email address "invalid@email.com"', Alert(self.browser).text) 
开发者ID:merenlab,项目名称:anvio,代码行数:10,代码来源:run_server_tests.py

示例10: test10DeleteProject

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import alert_is_present [as 别名]
def test10DeleteProject(self):
        self.login()
        WebDriverWait(self.browser, 5).until(EC.presence_of_element_located((By.ID, 'projectDelete0')))
        self.browser.find_element_by_id('projectDelete0').click()
        WebDriverWait(self.browser, 5).until(EC.alert_is_present())
        Alert(self.browser).accept()
        WebDriverWait(self.browser, 5).until(EC.visibility_of_element_located((By.XPATH, '//button[@title="upload data files"]')))
        self.assertFalse(len(self.browser.find_elements_by_link_text('test_proj_01'))) 
开发者ID:merenlab,项目名称:anvio,代码行数:10,代码来源:run_server_tests.py

示例11: test11DeleteUser

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import alert_is_present [as 别名]
def test11DeleteUser(self):
        self.loginAdmin()
        WebDriverWait(self.browser, 5).until(EC.presence_of_element_located((By.LINK_TEXT, 'admin page')))
        self.browser.find_element_by_link_text('admin page').click()
        WebDriverWait(self.browser, 5).until(EC.presence_of_element_located((By.XPATH, '//button[@onclick="showUserDetails(\'testuser2\');"]')))
        self.browser.find_element_by_xpath('//button[@onclick="showUserDetails(\'testuser2\');"]').click()
        WebDriverWait(self.browser, 5).until(EC.presence_of_element_located((By.XPATH, '//button[@onclick="deleteUser(\'testuser2\')"]')))
        self.browser.find_element_by_xpath('//button[@onclick="deleteUser(\'testuser2\')"]').click()
        WebDriverWait(self.browser, 5).until(EC.alert_is_present())
        Alert(self.browser).send_keys('CONFIRM')
        Alert(self.browser).accept()
        WebDriverWait(self.browser, 5).until(EC.presence_of_element_located((By.ID, 'usertable')))
        self.assertFalse(len(self.browser.find_elements_by_xpath('//button[@onclick="showUserDetails(\'testuser2\');"]'))) 
开发者ID:merenlab,项目名称:anvio,代码行数:15,代码来源:run_server_tests.py

示例12: wait_for_alert

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import alert_is_present [as 别名]
def wait_for_alert(self, **kwargs):
        '''
        Shortcut for waiting for alert. If it not ends with exception, it
        returns that alert.
        '''
        self._wait_for(EC.alert_is_present(), **kwargs) 
开发者ID:IntuitiveWebSolutions,项目名称:PyWebRunner,代码行数:8,代码来源:WebRunner.py

示例13: _find_modal

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import alert_is_present [as 别名]
def _find_modal(self, text=None, wait=None):
        wait = wait or capybara.default_max_wait_time
        try:
            alert = WebDriverWait(self.browser, wait).until(EC.alert_is_present())
            regexp = toregex(text)
            if not regexp.search(alert.text):
                qualifier = "matching" if isregex(text) else "with"
                raise ModalNotFound("Unable to find modal dialog {0} {1}".format(qualifier, desc(text)))
            return alert
        except TimeoutException:
            raise ModalNotFound("Unable to find modal dialog") 
开发者ID:elliterate,项目名称:capybara.py,代码行数:13,代码来源:driver.py

示例14: has_alert

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import alert_is_present [as 别名]
def has_alert(self):
        """
        Whether or not there is currently an alert present

        :return: True if there is an alert present, else False
        :rtype: bool
        """
        try:
            WebDriverWait(self, 1).until(EC.alert_is_present())
            alert = self.switch_to.alert
            return True
        except TimeoutException:
            return False 
开发者ID:spyoungtech,项目名称:behave-webdriver,代码行数:15,代码来源:driver.py

示例15: web_screen

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import alert_is_present [as 别名]
def web_screen(self, step, element):
        # 截图
        screen_v = self.output.get('#ScreenShot', '')
        element_v = self.output.get('#ElementShot', '')

        if g.snapshot or self.screen_flag or self.element_flag:
            from selenium.webdriver.support import expected_conditions as EC
            if not EC.alert_is_present()(g.driver):
                if self.expected.get('#ScreenName'):
                    screen_name = self.expected['#ScreenName']
                elif screen_v:
                    screen_name = screen_v
                else:
                    screen_name = ''
                if screen_name:
                    file_name = self.label + now() + '#Screen' + '[' + screen_name + ']' + '.png'
                else:
                    file_name = self.label + now() + '#Screen' + '.png'                                        
                step['snapshot']['Real_Screen'] = str(
                    Path(self.snapshot_folder) / file_name)
                get_screenshot(step['snapshot']['Real_Screen'])
                if screen_v:
                    g.var[screen_v] = step['snapshot']['Real_Screen']

        if element_v:
            file_name = self.label + now() + '#Element' + '[' + element_v + ']' + '.png'
            step['snapshot']['Real_Element'] = str(Path(self.snapshot_folder) / file_name)
            crop(element, step['snapshot']['Real_Screen'], step['snapshot']['Real_Element'])
            g.var[element_v] = step['snapshot']['Real_Element'] 
开发者ID:tonglei100,项目名称:sweetest,代码行数:31,代码来源:snapshot.py


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