()
driver.implicitly_wait (10) # Implicit wait and explicit wait can be used at the same time, but note that the longest wait time is the greater of
driver.get (‘https://xuehu365.com’)
locator = (By.LINK_TEXT, ‘CSDN’)
try:
WebDriverWait (driver, 20, 0.5) .until (EC.presence_of_element_located (locator))
print driver.find_element_by_link_text (‘CSDN’). get_attribute (‘href‘)
finally:
driver.close ()
In the example above, we set the implicit wait and explicit wait, in other operations, the
elementFind_element_by_partial_link_text (Link_text) find_elements_by_partial_link_text (Link_text)#Find part of a link to an element of textFind_element_by_tag_name (name) find_elements_by_tag_name (name)#Find the label name of an elementFind_element_by_xpath (XPath)#Find XPath for an element Find_elements_by_xpath (XPath) # find child elements within an element Xpath Find_element_by_class_name (name) # Find the class name of an element find_elements_by_ Class_name (name) # Find the class na
Python-selenium 2 Upgrade to the latest versionSelenium 2.48 was used before. firefox36The actual user's browser may have an automatic Update feature, so the version is basically up-to-date. So this time specifically to do a browser upgrade and selenium upgrade.Since Webdriver 3.0, selenium no longer provides default b
Setuptools-18.0.1.zip after extracting the storage path to execute, such as:C:\setuptools-18.0.1>python setup.py Install2. Install PipIt is easy to install Python packages with PIP. You need to install Setuptool before you install PIP. In Https://pypi.Python.org/pypi/pip download, the Pip-7.1.0.zip file extracted to any directory, decompression can find setup.py. Go to the Windows command prompt (Start-run
capturing or positioning.pop-up windowThe key is to get a handle to the popup window. I still like to illustrate by example: #-*-coding=utf-8from Selenium ImportWebdriverImport Unittestclass Login (unittest. TestCase): def setUp (self): Self.driver = Webdriver. Firefox () self.driver.implicitly_wait (+) Self.base_url = "/http" Www.baidu.com " self.verificationerrors = [] def test_ Loginpass (self): Driver = self.driver Driver.ge
Article Source: https://www.cnblogs.com/jshtest/p/6222923.html
In the process of automating development, sometimes in order to ensure the stability of the script, you need to add the wait time in the script.
Sleep (): Sets the fixed hibernation time. The Python time package provides hibernation (), and you can use sleep () to hibernate after the time package is imported.
Implicitly_wait (): Is a timeout waiting for Webdirver. Implicitly waiting for an
Because of some confusion, so prepare to direct the project
Start learning a python web-driven test without thinking that it was wrong in the first place.
Environment is the latest version of Python,selenium,firefox,django, etc.
Tap the code on the book
From selenium import webdriver
browser = webdriver. Firefox ()
br
/wKioL1j2DUPyp9RyAABIWks3_Cg729.png-wh_500x0-wm_ 3-wmp_4-s_2637081708.png "title=" Python installation succeeded. png "alt=" wkiol1j2dupyp9ryaabiwks3_cg729.png-wh_50 "/>Ok , Get here python The installation was successful. But to do the selenium test, you also need to install setuptools(to install other plug-in modules),directly run the line of sight download a g
Selenium+eclipse+junit+testng+python Step three download Selenium IDE,seleniumrc,iedriverserver, seleniumclient Drivers Selenium official website :http://www.seleniumhq.org/download/1 . Selenium IDE:selenium-ide-2.2.0.xpi is used to record scripts on Firefox. 2,
the downloaded PIP into the c:\python27 folder.execute the following command in Cmd: C:\python27\pip-8.1.2>python setup.py install;verify Pip and execute the following command in Cmd: C:\python27\scripts>pip4. Installing SeleniumCMD execution command: c:\python27\scripts>pip install selenium;Verify that the installation is Successful. Enter the Scripts directory and enter the following command:C:\python27
Installing SeleniumOpen Command Control input: Pip install-u SeleniumFirefox installs firebug:www.firebug.com, debugging all website language, debugging functionSelenium IDE is a plug-in embedded in the Firefox browser, the implementation of simple browser operation of the recording and playback functions, the IDE recorded scripts can be converted into multiple languages, so as to help us quickly develop the script: https:// addons.mozilla.org/en-us/firefox/addon/
Python + Selenium notes (3): Use unittest, seleniumunittest
# An error may occur when the network is slow.
(1) Preface
Selenium WebDriver is an API set for automated browser testing. It provides many features for automated interaction with browsers, and these APIs are mainly used to test Web programs. If Selenium WebDr
behave results in Baidu with Firefox browserGiven Access Baidu websiteWhen Input behave charactersThen there is more than 1 results displaying@browser. ChromeScenario:search behave results in Baidu with Chrome browserGiven Access Baidu websiteWhen Input behave charactersThen there is more than 1 results displaying@browser. ieScenario:search behave results in Baidu with IE browserGiven Access Baidu websiteWhen Input behave charactersThen there is more than 1 results displayingThird, in the Examp
1, can not start the browser, error is as follows:============================= ERRORS =============================Traceback (most recent):File "D:\python_files\eclipse_wrokstation\WinshareWebAotuTest\TestCase\testBookComments.py", line +, in SetUpSelf.driver = Webdriver. Chrome ()File "D:\Program files\python\python3\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line page, in __init_ _Desired
Learning Automation has always been in the native operation, feeling that this can reduce the amount of work really very little. Recently, we studied distributed operations.The idea was that I started the script on a single machine, and then let the script run on different versions of the browser on different machines.Things to prepare for:1, JDK, and environment variables are configured well. Run Javac under cmd If you don't get an error.2, Python de
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.