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


Python ui.WebDriverWait方法代码示例

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


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

示例1: submit_user_data

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
def submit_user_data(self):
        # Submit to Authent-Number Page (press button).
        wait = WebDriverWait(self.driver, timeout=6)
        try:
            self.driver.execute_script(
                'document.getElementsByTagName("button")[0].click()'
            )
            wait.until(
                EC.presence_of_element_located(
                    (By.ID, 'idRandomPic')
                )
            )
        except:
            self.label_show_result.setText(
                '【連線逾時或是網路不穩定】\n' + 
                '【請檢查網路環境以及是否為尖峰時段。】'
            ) 
开发者ID:gw19,项目名称:TRA-Ticket-Booker,代码行数:19,代码来源:TraTicketBooker.py

示例2: _wait_until

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
def _wait_until(self, condition_method, condition_input, timeout=None):
        """
        Common method to wait until condition met

        :param condition_method: method to check the condition
        :param condition_input: parameter that will be passed to the condition method
        :param timeout: max time to wait
        :returns: condition method response
        """
        # Remove implicitly wait timeout
        implicitly_wait = self.get_implicitly_wait()
        if implicitly_wait != 0:
            self.driver_wrapper.driver.implicitly_wait(0)
        try:
            # Get explicitly wait timeout
            timeout = timeout if timeout else self.get_explicitly_wait()
            # Wait for condition
            condition_response = WebDriverWait(self.driver_wrapper.driver, timeout).until(
                lambda s: condition_method(condition_input))
        finally:
            # Restore implicitly wait timeout from properties
            if implicitly_wait != 0:
                self.set_implicitly_wait()
        return condition_response 
开发者ID:Telefonica,项目名称:toolium,代码行数:26,代码来源:driver_utils.py

示例3: crack

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
def crack(self):
        true_image = self.get_true_image()
        x_offset = self.analysis(true_image)
        print(x_offset)

        track = self.get_track(x_offset)
        knob_element = WebDriverWait(self.driver, 50).until(
            EC.element_to_be_clickable((By.XPATH, r'/html/body/div[2]/div[2]/div[6]/div/div[1]/div[2]/div[2]')))
        self.move_to_gap(knob_element, track)

        # fn = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'result0.png')
        # fn1 = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'result1.png')
        # time.sleep(0.02)
        # screen_shot = self.driver.save_screenshot(fn)
        # time.sleep(2)
        # screen_shot = self.driver.save_screenshot(fn1) 
开发者ID:ForgQi,项目名称:bilibiliupload,代码行数:18,代码来源:__init__.py

示例4: login

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
def login(driver, user, password):
    wait = WebDriverWait(driver, 10)
    driver.get(
        'https://www.odoo.com/web/login?redirect=%2Foauth2%2Fauth%2F%3Fscope'
        '%3Duserinfo%26redirect_uri%3Dhttps%253A%252F%252Fapps.odoo.com%252F'
        'auth_oauth%252Fsignin%26state%3D%257B%2522p%2522%253A%2B1%252C%2B'
        '%2522r%2522%253A%2B%2522%25252F%25252Fapps.odoo.com%25252Fapps%25'
        '22%252C%2B%2522d%2522%253A%2B%2522apps%2522%257D%26response_type%3D'
        'token%26client_id%3Da0a30d16-6095-11e2-9c70-002590a17fd8&scope=user'
        'info&mode=login&redirect_hostname=https%3A%2F%2Fapps.odoo.com&login='
    )
    login_field = driver.find_element_by_id('login')
    login_field.clear()
    login_field.send_keys(user)
    password_field = driver.find_element_by_id('password')
    password_field.clear()
    password_field.send_keys(password)
    login_button = driver.find_element_by_xpath(
        './/form[@action="/web/login"]//button[@type="submit"]'
    )
    login_button.click()
    wait.until(
        lambda driver: driver.current_url == 'https://apps.odoo.com/apps'
    ) 
开发者ID:OCA,项目名称:maintainer-tools,代码行数:26,代码来源:publish_modules.py

示例5: __login

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
def __login(self):
        if self.debug: self.driver.save_screenshot(self.directory + r'01.png')
        txt_login = self.driver.find_element_by_id('ctl00_ContentPlaceHolder1_txtLogin')
        txt_login.clear()
        txt_login.send_keys(os.environ['CPF'])

        time.sleep(3.0)
        txt_senha = self.driver.find_element_by_id('ctl00_ContentPlaceHolder1_txtSenha')
        txt_senha.clear()
        txt_senha.send_keys(os.environ['SENHA_CEI'])
        time.sleep(3.0)

        if self.debug: self.driver.save_screenshot(self.directory + r'02.png')

        btn_logar = self.driver.find_element_by_id('ctl00_ContentPlaceHolder1_btnLogar')
        btn_logar.click()

        try:
            WebDriverWait(self.driver, 60).until(EC.visibility_of_element_located((By.ID, 'objGrafPosiInv')))
        except Exception as ex:
            raise Exception('Nao foi possivel logar no CEI. Possivelmente usuario/senha errada ou indisponibilidade do site')

        if self.debug: self.driver.save_screenshot(self.directory + r'03.png') 
开发者ID:guilhermecgs,项目名称:ir,代码行数:25,代码来源:crawler_cei.py

示例6: __init__

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
def __init__(self):
        self.browse = None
        self.source_playlist = None
        self.target_playlist_tag = None
        self.success_list = list()
        self.failed_list = list()
        os.environ["webdriver.chrome.driver"] = chrome_driver_path
        os.environ["webdriver.phantomjs.driver"] = phantomjs_driver_path
        # chromedriver = chrome_driver_path
        phantomjs_driver = phantomjs_driver_path

        opts = Options()
        opts.add_argument("user-agent={}".format(headers["User-Agent"]))
        # browser = webdriver.Chrome(chromedriver)
        browser = webdriver.PhantomJS(phantomjs_driver)
        self.browser = browser
        self.wait = ui.WebDriverWait(self.browser, 5)
        self.config = Config() 
开发者ID:Denon,项目名称:syncPlaylist,代码行数:20,代码来源:base.py

示例7: wait_for_element

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
def wait_for_element(driver: 'WebDriver', locator: str, value: str, timeout: int = SLEEPY_TIME) -> 'WebElement':
    """Wait until the element located

    Args:
        driver: WebDriver instance
        locator: Locator like WebDriver, Mobile JSON Wire Protocol
            (e.g. `appium.webdriver.common.mobileby.MobileBy.ACCESSIBILITY_ID`)
        value: Query value to locator
        timeout: Maximum time to wait the element. If time is over, `TimeoutException` is thrown

    Raises:
        `selenium.common.exceptions.TimeoutException`

    Returns:
        The found WebElement
    """
    return WebDriverWait(driver, timeout).until(
        EC.presence_of_element_located((locator, value))
    ) 
开发者ID:appium,项目名称:python-client,代码行数:21,代码来源:test_helper.py

示例8: sign_off

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
def sign_off(self):
        """Submit questionnaire and finish.

        This uses Selenium to click the submit button on the questionnaire
        and return to the original window.
        """
        try:
            logger.info("Bot player signing off.")
            feedback = WebDriverWait(self.driver, 20).until(
                EC.presence_of_element_located((By.ID, "submit-questionnaire"))
            )
            self.complete_questionnaire()
            feedback.click()
            logger.info("Clicked submit questionnaire button.")
            self.driver.switch_to_window(self.driver.window_handles[0])
            self.driver.set_window_size(1024, 768)
            logger.info("Switched back to initial window.")
            return True
        except TimeoutException:
            logger.error("Error during experiment sign off.")
            return False 
开发者ID:Dallinger,项目名称:Dallinger,代码行数:23,代码来源:bots.py

示例9: wait_for_text

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
def wait_for_text(driver, el_id, value, removed=False, timeout=10):
    el = wait_for_element(driver, el_id, timeout)
    if value in el.text and not removed:
        return el
    if removed and value not in el.text:
        return el

    wait = WebDriverWait(driver, timeout)
    condition = EC.text_to_be_present_in_element((By.ID, el_id), value)
    if removed:
        wait.until_not(condition)
        if value not in el.text:
            return el
    else:
        wait.until(condition)
        if value in el.text:
            return el

    raise AttributeError 
开发者ID:Dallinger,项目名称:Dallinger,代码行数:21,代码来源:pytest_dallinger.py

示例10: click_tiles

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
def click_tiles(driver, coords):
    orig_srcs, new_srcs = {}, {}
    for (x, y) in coords:
        logging.debug("[*] Going to click {} {}".format(x,y))
        tile1 = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, '//div[@id="rc-imageselect-target"]/table/tbody/tr[{0}]/td[{1}]'.format(x, y))))
        orig_srcs[(x, y)] = driver.find_element(By.XPATH, "//*[@id=\"rc-imageselect-target\"]/table/tbody/tr[{}]/td[{}]/div/div[1]/img".format(x,y)).get_attribute("src")
        new_srcs[(x, y)] = orig_srcs[(x, y)] # to check if image has changed 
        tile1.click()
        wait_between(0.1, 0.5)

    logging.debug("[*] Downloading new inbound image...")
    new_files = {}
    for (x, y) in orig_srcs:
        while new_srcs[(x, y)] == orig_srcs[(x, y)]:
            new_srcs[(x, y)] = driver.find_element(By.XPATH, "//*[@id=\"rc-imageselect-target\"]/table/tbody/tr[{}]/td[{}]/div/div[1]/img".format(x,y)).get_attribute("src")
            time.sleep(0.5)
        urllib.urlretrieve(new_srcs[(x, y)], "captcha.jpeg")
        new_path = TASK_PATH+"/new_output{}{}.jpeg".format(x, y)
        os.system("mv captcha.jpeg "+new_path)
        new_files[(x, y)] = (new_path)
    return new_files 
开发者ID:ecthros,项目名称:uncaptcha,代码行数:23,代码来源:main.py

示例11: test_stick_to_top_admin

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
def test_stick_to_top_admin(self):
        self.browser.get(self.live_server_url + reverse("niji:index"))
        login(self.browser, 'super', '123')
        self.assertIn("Log out", self.browser.page_source)

        lucky_topic1 = getattr(self, 't%s' % random.randint(1, 50))

        self.browser.get(self.live_server_url+reverse('niji:topic', kwargs={"pk": lucky_topic1.pk}))
        self.browser.find_element_by_class_name('move-topic-up').click()
        up_level = WebDriverWait(
            self.browser, 10
        ).until(
            expected_conditions.presence_of_element_located(
                (By.NAME, 'move-topic-up-level')
            )
        )
        up_level = Select(up_level)
        up_level.select_by_visible_text('1')
        time.sleep(1)
        self.browser.execute_script("$('.modal-confirm').click()")
        self.browser.get(self.live_server_url+reverse('niji:index'))
        first_topic_title = self.browser.find_elements_by_class_name('entry-link')[0].text

        self.assertEqual(first_topic_title, lucky_topic1.title) 
开发者ID:ericls,项目名称:niji,代码行数:26,代码来源:tests.py

示例12: Single_Issue

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
def Single_Issue(url,Quality):
	#print url
	print 'Quality To Download : ',Quality[0]
	print 'Order To Download : ',Quality[1]
	#sys.exit()
	#print url,' This is first'
	
	browser = webdriver.PhantomJS(service_args=['--load-images=no'])
	browser.get(url)
	try:
		element = WebDriverWait(browser, 10).until(
			EC.presence_of_element_located((By.ID, "stSegmentFrame"))
		)
		#print 'Downloading the whole page! Will take some time, please don\'t close this script...\n'
		#print 'I\'ve waited long enough'
	except Exception, e:
		#raise e
		browser.save_screenshot('Single_exception.png')
		print e
		pass 
开发者ID:Xonshiz,项目名称:ReadComicOnline-Downloader,代码行数:22,代码来源:readcomic.py

示例13: __init__

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
def __init__(self, wait, screenshot=None, session=None):
        chrome_options = Options()
        if session:
            chrome_options.add_argument("--user-data-dir={}".format(session))
            self.browser = webdriver.Chrome(options=chrome_options)  # we are using chrome as our webbrowser
        else:
            self.browser = webdriver.Chrome()
        self.browser.get("https://web.whatsapp.com/")
        # emoji.json is a json file which contains all the emojis
        with open("emoji.json") as emojies:
            self.emoji = json.load(emojies)  # This will load the emojies present in the json file into the dict
        WebDriverWait(self.browser,wait).until(EC.presence_of_element_located(
            (By.CSS_SELECTOR, '._3FRCZ')))
        if screenshot is not None:
            self.browser.save_screenshot(screenshot)  # This will save the screenshot to the specified file location

    # This method is used to send the message to the individual person or a group
    # will return true if the message has been sent, false else 
开发者ID:VISWESWARAN1998,项目名称:Simple-Yet-Hackable-WhatsApp-api,代码行数:20,代码来源:whatsapp.py

示例14: send_message

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
def send_message(self, name, message):
        message = self.emojify(message)  # this will emojify all the emoji which is present as the text in string
        search = self.browser.find_element_by_css_selector("._3FRCZ")
        search.send_keys(name+Keys.ENTER)  # we will send the name to the input key box
        try:
            send_msg = WebDriverWait(self.browser, self.timeout).until(EC.presence_of_element_located(
                (By.XPATH, "/html/body/div/div/div/div[4]/div/footer/div[1]/div[2]/div/div[2]")))
            messages = message.split("\n")
            for msg in messages:
                send_msg.send_keys(msg)
                send_msg.send_keys(Keys.SHIFT+Keys.ENTER)
            send_msg.send_keys(Keys.ENTER)
            return True
        except TimeoutException:
            raise TimeoutError("Your request has been timed out! Try overriding timeout!")
        except NoSuchElementException:
            return False
        except Exception:
            return False

    # This method will count the no of participants for the group name provided 
开发者ID:VISWESWARAN1998,项目名称:Simple-Yet-Hackable-WhatsApp-api,代码行数:23,代码来源:whatsapp.py

示例15: get_last_seen

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
def get_last_seen(self, name, timeout=10):
        search = self.browser.find_element_by_css_selector("._3FRCZ")
        search.send_keys(name+Keys.ENTER)  # we will send the name to the input key box
        last_seen_css_selector = "._315-i"
        start_time = dt.datetime.now()
        try:
            WebDriverWait(self.browser,self.timeout).until(EC.presence_of_element_located(
                (By.CSS_SELECTOR, last_seen_css_selector)))
            while True:
                last_seen = self.browser.find_element_by_css_selector(last_seen_css_selector).text
                if last_seen and "click here" not in last_seen:
                    return last_seen
                end_time = dt.datetime.now()
                elapsed_time = (end_time-start_time).seconds
                if elapsed_time > 10:
                    return "None"
        except TimeoutException:
            raise TimeoutError("Your request has been timed out! Try overriding timeout!")
        except NoSuchElementException:
            return "None"
        except Exception:
            return "None"

    # This method does not care about anything, it sends message to the currently active chat
    # you can use this method to recursively send the messages to the same person 
开发者ID:VISWESWARAN1998,项目名称:Simple-Yet-Hackable-WhatsApp-api,代码行数:27,代码来源:whatsapp.py


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