Discover css selector in selenium webdriver, include the articles, news, trends, analysis and practical advice about css selector in selenium webdriver on alibabacloud.com
Original URL:
Http://www.cnblogs.com/fnng/p/3183777.html
This section focuses on: positioning of Simple objects
-----The core of automated testing
Object positioning should be the core of automated testing, in order to manipulate an object, you should first identify the object. An object is a person, he will have a variety of characteristics (attributes), such as we can through a person's ID number, name, or he lives in which street, floor, number of people find this person.
Then an object has
screenshot work, need to use the Selenium Webdriver and Selenium IDE These two tools, in view of this article mainly introduces the TVT automatic screenshot, the detailed Selenium knowledge, here no longer introduces, everybody may go to its official website to understand more related Knowledge.
To work with the
, and core. Where selenium core is embedded in the browser page by Selenium core (a collection of JavaScript functions). Launcher is used to launch the browser, load the selenium core into the browser page, and set the browser proxy to selenium Server's HTTP proxy.2. Selenium
Selenium Webdriver Learning Summary-element positioning Webdriver provides a rich API with a variety of positioning strategies: Id,name,css selector, XPath, etc., where CSS selector pos
-----The core of automated testing
Object positioning should be the core of automated testing, in order to manipulate an object, you should first identify the object. An object is a person, he will have a variety of characteristics (attributes), such as we can through a person's ID number, name, or he lives in which street, floor, number of people find this person.
Then an object has a similar attribute, and we can find this object through this property.
There are several common purposes for
usage, if skilled can be more convenient to help us locate elements, such as we can use ^ to match a prefix, $ to match a suffix, * to match any character. For example:Matches an id attribute, and the id attribute is a hyperlink element that begins with "Id_prefix_": a[id^= ' id_prefix_ ']Match an id attribute, and the id attribute is the hyperlink element ending with "_id_sufix": a[id$= ' _id_sufix ']Match a hyperlink element that has an id attribute and an id attribute that contains the "Id_p
):defTest (self): Driver_wrapper= Driverwrapper (1) Driver_wrapper.open ('https://www.baidu.com')#Some people don't like to use GET, can call open whatDriver_wrapper.find_element_by_css_selector ('#kw')#when a method exists in a class, the method in its own class is preferred, so a log is printed each time a CSS selector is used to find an elementDRIVER_WRAPPER.FIND_ELEMENT_BY_ID ('kw')#when this method doe
id attribute is a hyperlink element that begins with "Id_prefix_": a[id^= ' id_prefix_ ']Match an id attribute, and the id attribute is the hyperlink element ending with "_id_sufix": a[id$= ' _id_sufix ']Match a hyperlink element that has an id attribute and an id attribute that contains the "Id_pattern" character: a[id*= ' Id_pattern ')Finally, a summary of the various ways to choose the time should be how to choose:1. When the page element has an id attribute, it is best to use ID to locate i
example: Safari, FF Drive the browser itself in the form of plug-ins, ie, chrome is the binary files to drive the browser itself;These driver are launched directly and driven by invoking the browser's underlying interface to drive the browser, thus having the most realistic user scenario simulations, primarily for web compatibility testing use.One is pseudo browser driver (not working in the browser, only relevant information is provided here)Selenium
: Safari, FF Drive the browser itself in the form of plug-ins, ie, chrome is the binary files to drive the browser itself;These driver are launched directly and driven by invoking the browser's underlying interface to drive the browser, thus having the most realistic user scenario simulations, primarily for web compatibility testing use.One is pseudo browser driverSelenium supported pseudo-browsers include Htmlunit, PHANTOMJS; they are not really in the browser, there is no GUI, but with the sup
" character: a[id*= ' Id_pattern ')Finally, a summary of the various ways to choose the time should be how to choose:
When the page element has an id attribute, it is best to use the ID to locate it. However, because many programmers in the real project actually write code that is not canonical, and will lack many standard attributes, then only choose other location method.
XPath is tough, but the positioning performance is not very good, so try to use less. If you do not have a few
Webdriver provides a rich API, a variety of positioning strategies: id,name,css selectors, XPath, etc., where CSS selector positioning element efficiency is higher than XPath, using the Id,name attribute to locate the element is the most reliable and most efficient way.1, tool selection: In our development test script
(\ "User_name\") The ID of element Q is user_name Q.style.border=\ "1px solid red\The style of element Q with a border of 1 pixels red Hide elementsJs.htmlHtml>Head>MetaHttp-equiv= "Content-type"Content= "Text/html;charset=utf-8"/>Title>jsTitle>ScriptType= "Text/javascript"Async=""Src= "Http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">Script>LinkHref= "Http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combine
("Button.btn.btn_big.btn_submit"))。 This makes it easy to refer to elements that use a composite style.In addition, Cssselector also has some advanced usage, if skilled can be more convenient to help us locate elements, such as we can use ^ to match a prefix, $ to match a suffix, * to match any character. For example:Matches an id attribute, and the id attribute is a hyperlink element that begins with "Id_prefix_": a[id^= ' id_prefix_ ']Match an id attribute, and the id attribute is the hyperli
Web page automation testing, the elements on the page positioning and operation is the core. And the operation is the premise of positioning, therefore, the positioning of page elements is the basis for automated testing.
The elements on the page, like people, have various attributes, such as element names, element IDs, element attributes (class attributes, name attributes), and so on. Webdriver is the use of these attributes of elements to locate.
Co
http://www.testclass.net/ Test Tutorial Network, professional Selenium learning website.This sectionto solves the problem:How do I locate a set of elements?SceneAs you can see from the example in the previous section, Webdriver can easily use the Findelement method to locate a particular object, but sometimes we need to locate a group of objects,This is the time to use the Findelements method.Locating a gro
1.Webdriver principleWebdirver is a Web automation tool that provides a unified Webdriver interface to the browser, which is submitted by client, our test script, and the remote server browser responds to the request. Compared to the original selenium1 in the Selenium RC is more convenient, the browser operation more flexible.2. Positioning(1) Positioning of elem
When you use selenium webdriver for element positioning, you typically use the Findelement or Findelements method to position the element with the element handle returned by the by class.Among them, by the common positioning method of eight kinds, are described below respectively.1. By.name ()Suppose we want to test the source of the page as follows:When we want to use the Name property to refer to this but
Selenium webdriver Learn, select module, click Next page, get current URLFind the next page there are several methods, here are listed two kinds;The isSelected () function is used to determine whether a click is selected to return a Boolean typeImport Org.openqa.selenium.By;Import Org.openqa.selenium.WebDriver;Import org.openqa.selenium.WebElement;Import Org.openqa.selenium.chrome.ChromeDriver;Import java.u
Original address: Http://www.seleniumhq.org/docs/03_webdriver.jsp#selenium-webdriver-api-commands-and-operations
(This article is only for the Python part of the translation)
First of all, I have a point: my English is very poor, so this translation is only used to understand more deeply the use of webdriver.
First, get the page
The first step in using
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.