Install python (https://www.python.org/), download the latest Python version
Configure environment variables. (Example), I installed Python under/installation folder with Python 3.5.2. The path set is as follows:d:\installation\python3.5.2;d:\installation\python3.5.2\scrip
Selenium is a tool that allows the browser to automate a series of tasks, often used for automated testing. However, it can also be used to give Web pages. Currently, it supports four client languages for Java, C #, Ruby, and Python. If you use Python, you only need to enter "sudo easy_install selenium" on the command
Installing Selenium with PipDownload Chromedriver, add in Path#-*-coding:utf-8-*- fromSeleniumImportWebdriver fromSelenium.common.exceptionsImporttimeoutexception fromSelenium.webdriver.support.uiImportWebdriverwait#available since 2.4.0Import Time#Create A new instance of the browser driverDriver = Webdriver. Chrome ()##可以替换为IE (), Firefox () Chrome ( ) #go to the Google home pageDriver.get ("https://www.google.com") #find the element that's na
span >Use Beatuifulsoup to get the element with the following code:# number of spectators numbers = Soup.find_all("span", {"class" :" dy-num fr"})The process is probably the case, here is the complete code:#!/usr/bin/env python#-*-coding:utf-8-*- fromSeleniumImportWebdriver fromBs4ImportBeautifulSoup as BSImportsysreload (SYS) sys.setdefaultencoding ("Utf-8")classDouyu ():def __init__(self): Self.driver=Webdriver. PHANTOMJS () Self.num=0 Self.count=
SceneFor pagination, we are most interested in the following information
How many pages are there in total
How many pages are you currently on?
Can I have a previous page and a next page?
CodeThe following code shows how to get the total paging and the current page, jump to a specified number of pages#Coding:utf-8 fromSeleniumImportWebdriverImportTimedriver=Webdriver. Chrome () Driver.get ("https://segmentfault.com/news")#get the number of all pagination#-2 is because you w
) self.asserttrue (self.is_content_present ("%s"% Expected_ Value) def is_element_present (self, how, what): "" "Utility method to check presence of an Elem ENT on page:p arams how:by locator type:p arams what:locator value "" "Try:self . Browser.find_element (By=how, value=what) except Nosuchelementexception, _: Return False return T Rue def is_content_present (self, What): "" "Utility method to check presence of a element on page :p arams what:content value "" "Try:self.browser.find_ele
Address of the remote machine. Test result can be verified on the default TestNG report generatedSummary
Selenium Grid is used to run multiple tests simultaneously on different browsers and platforms.
Grid uses the Hub-node concept.
The hub is the central point wherein you load your tests.
Nodes is the Selenium instances that'll execute the tests that's loaded on the hub.
To instal
Install selenium in python and python seleniumInstall python
Go to the Python official website, find "Download", and select your own platform (Windows/Mac) from the drop-down menu. Generally, you do not need to install Python on t
Python + Selenium notes (11): Configure selenium Grid and pythonselenium
(1)Preface
Selenium GridTests can be distributed on several physical or virtual machines to perform tests in a distributed or parallel manner.
This link is an official description.
Https://github.com/SeleniumHQ/
api:http://phantomjs.org/api/.PHANTOMJS Official example: http://phantomjs.org/examples/.Phantomjs github:https://github.com/ariya/phantomjs/.Iv. installation of PHANTOMJSI windowns7 the system, the downloaded phantomjs.exe moved to your Python folder under the script can be used. (Download Phantomjs-2.1.1-windowns.zip Link: http://pan.baidu.com/s/1c8HeBc password:2zm4)Small test:1 From
SeleniumThe Ultimate Automated test Environment Setup (II.)Selenium+eclipse+pythonThe previous example of the selenium+eclipse+junit+testng Automated test environment, on the basis of the previous article, the following example Selenium+eclipse+
/.
Official PhantomJS API: http://phantomjs.org/api /.
Official PhantomJS example: http://phantomjs.org/examples /.
PhantomJS GitHub: https://github.com/ariya/phantomjs /.4. Install PhantomJS
In the Windows 7 system, move the downloaded phantomjs.exe file to the Script in your python folder. (Download phantomjs-2.1.1-windowns.zip link: http://pan.baidu.com/s/1c8HeBc password: 2zm4)
Small test:
1 from
interpreter,selenium can be downloaded according to my first blog's practice. PHANTOMJS, you can directly through the link I gave to download. When the two are all installed, you can start data capture formally. Of course, the example is my blog ~First on the sample code!#-*-coding:utf-8-*-# fromSeleniumImportWebdriverdefcrawling_webdriver ():#get local session of PHANTOMJSDriver = Webdriver. PHANTOMJS (ex
of Selenium-webdriver, I found that the principle of webdriver is not inscrutable speculate. Here is an example of the firefox-webdriver implementation of Webdriver Ruby binding, which briefly describes how Webdriver works.When the test script starts Firefox, Selenium-webdriver will start the Firefox browser in the new thread first. If the test script specifies
through LinkSometimes not an input box is not a button, but a text link, we can#coding =utf-8FromseleniumimportwebdriverImporttimeDF = Webdriver. Firefox () #选择firefox浏览器Df.get ("http://www.baidu.com") #打开百度网页Time.sleep (2) #暂停2秒, not millisecondsDf.find_element_by_link_text ("Paste"). Click () #点击贴吧链接Time.sleep (2)Df.quit () #关闭浏览器Partiallinktext PositioningThrough part of the link location, this is sometimes used, I have not thought of good use. With the above
as XX time, whether the bump can keep up with the speed, or has been early, must wait xx time.Look at the code:# -*- coding: utf-8 -*-from selenium import webdriverfrom time import sleepdriver = webdriver.Firefox()driver.get(‘https://huilansame.github.io‘)sleep(3) # 强制等待3秒再执行下一步print driver.current_urldriver.quit()This is called forced wait, regardless of whether your browser is loaded, the program will have to wait 3 seconds, 3 seconds to continue t
Selenium (1): selenium installation in Python, seleniumpythonAbout selenium
Selenium is also a tool for Web application testing. The Selenium test runs directly in the browser, just as the real user is operating. Supported browser
First, Test System: Python + Selenium + pycharm + Jenkins/dockerEnvironment Construction:1. Install python 3.4/3.5 2/3.6/3.72. Configure Environment variables3.pip Install selenium== version number 3.3 (frame with the latest in mature language)4. Install editor Pycharm, Project path cannot contain Chinese, name is mean
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.