The content in this part will be a demonstration of the positioning Element Method in WebDriver, which is a combination of methods used in the WebDriver of Selenium element locating command.
For a review of element locating methods in Selenium, refer:
The positioning and operation of the test object is the core cont
Pre-condition: Python pip is already installed in the system.Step One: Enter the PIP installation directory in cmd, such as: D:\python34\scriptsStep Two: Execute the installation command: Pip install selenium after the installation of the browser-driven configurationStep three: Download browser drivers on the Internet (Google, IE, Firefox, etc.)Fourth step: Place the downloaded browser driver in the root di
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
PlainCopy
Username = Driver.find_element_by_xpath ("//form[input/@name = ' username ']")
Username = Driver.find_element_by_xpath ("//form[@id = ' loginform ']/input[1]")
Username = Driver.find_element_by_xpath ("//input[@name = ' username ']")
[1] The first FORM element is implemented by an input child element, the Name property and the value username[2] The first input child element is found by a form element of the Id=loginform value[3] The first INPUT element with the n
Action Date Elementthe first way to enter a date directly into the input boxDateinputbox = self.driver.find_element_by_id ("DatePicker")Dateinputbox.send_keys ("11/24/2016")#encoding =utf-8From selenium import WebdriverImport UnitTest, Time, TracebackFrom Selenium.webdriver.support.ui import webdriverwaitFrom selenium.webdriver.common.by Import byFrom Selenium.webdriver.support import expected_conditions as ECFrom selenium.common.exceptions import Tim
Problem: selenium.common.exceptions.WebDriverException:Message: ' chromedriver ' executable needs to being in PATH. Please see Https://sites.google.com/a/chromium.org/chromedriver/homeCause: The hint was not added to the PATH environment variable and Webdriver was not foundSolution: Win10 used to add Chromedriver directory to the PATH environment variable, but still reported the same error, after searching, found to put Chromedriver.exe in the same di
Python selenium three waiting methods (required), pythonselenium
Many people ask in the group that the drop-down box cannot be located, the pop-up box cannot be located... In most cases, there are two problems: frame and wait. I don't know what kind of speed your code is running, but what kind of speed does the browser load and render? It's like the relationship between flash and tomman to beat monsters, th
The send_keys in WebDriver is used to simulate keyboard key input.
The send_keys method can simulate some key combinations:
Ctrl +
Ctrl + c
Ctrl + v
.
In addition, sometimes we need to use the tab key to move the focus to the next element during the test, and send_keys is also required. In some more complex cases, send_keys can also be used to simulate up/down keys to operate the drop-down list.
Test HTML code:
pythonhttps://www.python.org/Python is a scripting language that is easy to learn and easy to use, enabling you to quickly implement business logic and integrate systems efficiently.-----Http://zh.wikipedia.org/zh-cn/Python:Its syntax is simple, unlike most other programming languages using curly braces, which use indentation to define a block of statements.Python is often used for web development. For example, with the Mod_wsgi module, Apache can run
Selenium3.2. Install by download packageor download the Selenium package directly:Https://pypi.python.org/pypi/seleniumUnzip, cmd into the directory:c:\selenium\selenium2.53.5> python3 setup.py Install===============================================How to install under Ubuntu:1. Installation: Setuptools[Email protected]:~# apt-get Install Python-setuptools2. Inst
Explanation of the waiting method of Python selenium, pythonselenium
I found that too many people will not wait. Today, I can't help but tell you the necessity of waiting.
Many people ask in the group that the drop-down box cannot be located, the pop-up box cannot be located... In most cases, there are two problems: frame and wait. I don't know what kind of speed your code is running, but what kind of speed
See the forum someone wrote the Java test code of the daily design, to share with you how I usually test the testThe. Code is primarily based on the Python language. Daily debugging based on Webdriver is very handy in Python interactive mode,Open Python has interactive mode:Web-side Example:
From
1 Introduction and InstallationWhat is Selenium? In a word, automated testing tools. It supports a variety of browsers, including Chrome,safari,firefox and other mainstream interface browser, if you install a Selenium plug-in in these browsers, then you can easily implement the Web interface testing. In other words, call Selenium to support these browser drivers.
install (http://www.java.com/zh_CN/download/chrome.jsp? Locale = zh_cn) What? You have never completed java. Please refer to other documents! This is not difficult.
8. Download selenium server (https://code.google.com/p/selenium/) found in the list on the left side of the page
Selenium-server-standalone-XXX.jar
Yes! Download and decompress the package;
image module to intercept specific areas, the code is as follows:Idea: Save Web Programs--navigate to verification code coordinates--and then verify code location fromFrom PIL import imageimport pytesseractfrom Selenium import webdriverurl= ' http://xxxxx.com ' driver = webdriver. Chrome () Driver.maximize_window () #将浏览器最大化driver. Get (URL) driver.save_screenshot (' f://aa.png ') #截取当前网页, The page has t
obtained above, save to UPFILE.AU3;; Controlfocus ("title", "Text", ControlID) Edit1=edit instance 1Controlfocus ("File Upload", "", "Edit1"); Wait ten seconds for the Upload window to appearWinwait ("[CLASS: #32770]", "", 10); Set the File name Thext on the Edit fieldControlsettext ("File Upload", "" "," Edit1 "," E:\Python\20170109 (pyton+selenium) \test.png ")Sleep (2000); Click on the Open buttonContro
page, which is the biggest feature.
Operations in Python
Be sure to put Chromedriver in the same folder before writing the code, because we need to refer to path, so it's convenient. First of all our first task is to brush out 加载更多 the button and need to do 3 times to repeat the pulley three times to slide the center of the page , here for convenience I slipped to the bottom
From selenium import webdriveri
Hello, everyone sir Good, today I tell you how to use Python+selenium to do automated testing, landlord in the development test before doing Java development, for various reasons, the landlord turned into a development test, and then self-taught the script language Linux and Python, for these two scripts, I am very fond of, for what, because the efficiency is too
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.