Selenium python (v) Print information and set wait time

Source: Internet
Author: User
Tags set time selenium python

#!/usr/bin/python
#-*-Coding:utf-8-*-
__author__ = ' Zuoanvip '

#一般情况下我们要验证打开的页面是否正确, can be verified by the title and Current_url of the Web page

From selenium import Webdriver
Driver = Webdriver. Firefox ()
Driver.get (' http://www.baidu.com ')


#获取当前的网页标题
Driver.title

#获取当前的页面URL
Driver.current_url


#设置等待时间, there are three ways: sleep () fixed wait time, implicitly_wait () Smart wait, over time to throw an exception, webdriverwait () in the set time interval of every interval of detection, if not detected, throw an exception

#导入WebDriverWait包
From Selenium.webdriver.support.ui import webdriverwait

#导入time包
Import time

#WebDriverWait包的用法
element = Webdriverwait (driver,10). Until (Lambda driver:driver.find_element_by_id (' xx '))

#implicitly用法
Driver.implicitly_wait (10)


#添加固定休眠时间
Time.sleep (5)

Selenium python (v) Print information and set wait time

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.