Python selenium parent and child, brother, and adjacent node locating methods, pythonselenium
Today, I want to share with you the selenium Method for locating parent and child nodes, brothers, and adjacent nodes. Many people may find that the node they want to locate cannot be directly located in actual applications, it is easy to locate the child node from the p
Selenium does not have a browser, and it needs to be combined with a third-party browser. For example, run selenium on Firefox.Phantomjs is a "headless" browser. It loads the site into memory and executes the JavaScript on the page, but it does not show the user the graphical interface of the page. By combining selenium and PHANTOMJS, you can run a very powerful
Recently picked up before using Python + Selenium to implement work required to sign in to Office 365 features. (Spit Groove: The domestic network is really a card, logging into Office 365 is not easy.) In addition selenium such a site to the wall, can not understand, is said to be using Google's ip,whatever ... )Try to study the relationship between
Python + selenium + autoit implements the file upload function,
Problem
When automating the web ui Layer, you may encounter file upload operations. Some friends often ask, so here is a summary.
Solution
First: type = file Upload file, similar to the following
The following code can be used:
Driver. find_element ('name', 'file'). send_keys ('./Xiaoqiang test brand .png ')
The second type is exclusive to the
1.Python Download and install ?Go to the Python website first download the installation package:http://www.python.org/After downloading, follow the steps to install (preferably do not install to the system disk)Add the installation path (Python and scripts) to the system environment variables: computer--Properties--Advanced system settings, System variable path2
Recently in a script to try an automatic punch, found a few questions, hereby recorded.Environment:Ubuntu 12.04.4 LTSSelenium 2.43.0Firefox 32.0.31 Originally the machine Selenium,firefox are installed, but Firefox updates from time to time, so selenium may not support the current version of Firefox.Update Selenium command:sudo pip install-u Selenium2
-up message prompts, unavoidable to input Chinese, so this basic is necessary.2, "from...import ...andImport"2.1From...import: Only one class in a package is introducedExample: fromSelenium import WebdriverImport the Webdriver class in the Selenium package2.2Import: Is the introduction of the entiredatetimePackageFor example:import timeImport Time Entire Package3, "Try: .....except Exception as E:.....finally:....."
SceneThe positioning and operation of the test object is the core content of Webdriver, and the operation is based on the positioning, so the object positioning becomes more and more important.The purpose of locating objects generally has the following types of
Manipulating objects
Gets the properties of the object, such as the class property of the test object, the Name property, and so on
Gets the text of the object
Get the number of objects
Webdriver provides a serie
1. Install Pythonhttps://www.python.org/2, install setuptools(Python's basic Package tool):https://pypi.python.org/pypi/setuptoolsDownload ez_setup.py fileOpen cmd, go to the directory where the ez_setup.py file is stored, execute the python ez_setup.py3. Install pip(Python's installation package management tool):https://pypi.python.org/pypi/pip, download pip-6.1.1.tar.gzCMD into the file directory after decompression, execute
(' login ') signin_submit_ Button.Click () Time.sleep (2) # Exit Driver.close ()This is one of the simplest examples of Python selenium, and the added functionality will be based on a simple example of this extensionThen give an example of the official website, you can analyze, analysis can be confirmed by the last officer net, attached linkFrom selenium import
Prepare Python environment and install selenium., pythonselenium
1. Install python and selenium.
I use python 3.5, the following is the example
1.) Python download: 3.5
Https://www.python.org/downloads/release/
) is checked. fails if the specified element doesn ' T exist or isn ' t a toggle-button. Get_alert (): Retrieves the message of a JavaScript alert generated during the previous action, or fail if there were no Al ERTs. Getting an alert has the same effect as manually clicking OK. If an alert are generated but you don't consume it with Getalert, the next Selenium actionn Bsp would fail. Under Selenium, JavaS
xpath/copy selectorBy_xpath: "//*[@id =" kw "]"By_css_selector: "#kw"four summaryjust so. WebUI element Positioning is the core, because the element must be positioned before manipulating the element, so the element positioning is the difficulty, because selenium provides the method of locating elements, but some scenarios directly apply the method will be error, such as the element is embedded into the Frame, there are many identical elements, bulle
begins
personal Blog "Python+selenium GUI Automation implementation" mentioned in Chrome and IE browser call plugin has been uploaded to 51CTO download, the corresponding links are : Chrome,/http/ Down.51cto.com/data/2171584;ie,http://down.51cto.com/data/2171585; direct download is required; Body
With regard to automation, the essence is to use machine operation instead of manual execution, ther
One, Python installation (Win7 64-bit system)1. Download the Python installation package, select both version 2.7 and version 3.6 toOfficial website: https://www.python.org/2.Python installation, double-click the Fool installation to D-plate (recommended not installed on the C-drive)Second, environment variables1. After the installation is complete, look at this
Download plugin:
Python:https://wiki.jenkins-ci.org/display/jenkins/python+pluginRobotframework:https://wiki.jenkins-ci.org/display/jenkins/robot+framework+pluginSelenium:https://wiki.jenkins-ci.org/display/jenkins/selenium+plugin
Plugin use:
Place the downloaded. hpi file in this directory:D:\apache-tomcat-7.0.67\webapps\jenkins\WEB-INF\plugins (Tomcat installation directory)
Wh
About Selenium + python webdirver Google browser and IE driver configuration, when using these two browsers, you need to configure the driver to add to path, in addition to the other is to add the path, no need to configure the PATH environment variableTo add a case, add it according to the path location:Browser=webdriver. Chrome (' C:/users/wuzhiyi/appdata/local/google/chrome/application/chromedriver.exe '
Use Python+selenium automation to do a cnblog login test, can be used for reference! The following includes the test code and each of the test cases:The login test of the Cnblog is divided into the following situations: (1) The username and password are correct (2) The username is correct, the password is incorrect (3) The username is correct, the password is blank (4) The user name is wrong, the password i
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.