related to link1 Byid related to IDTwo Byxpath and Bycssselector left.My most common thing byxpath (or cssselector) because in many cases, HTML tag properties are not well-regulated and cannot be located by a single attribute, this time only using XPath can be used to re-implement the positioning of the unique elementIn fact the fastest positioning should belong to Byid, because the ID is unique, but most developers do not set the ID5. Where to go to
choose another location method
2. Cssselector execution speed, recommended use
3. When positioning hyperlinks, you can consider Linktext or partiallinktext: But note that the text changes frequently, so it is not recommended
4. XPath is the most powerful. The execution was slow because it was necessary to find the entire DOM, so try to use less. When there's no way to use XPath
Find elements by ID: by.
Selenium Webdriver automated testing design (webdriver automated architecture design, interface definition, log processing, Java Robot applications), webdriverrobot
I would like to share with you a set of courses. If you are interested, you can add me 2748165793
For more free information, see http://blog.sina.com.cn/sonyandnokia
Happy Park of mainong
Course outline
1st chapter:
Course Overview
SeleniumIt is of great help for us to carry out automated Web Testing. If we want to perform a wide range of testing coverage, we can't just run on one or two machines; selenium-grid also provides us with such help. We can easily build a distributed test environment with selenium-grid. Different from other common distributedProgram[Example: Hudson] selenium-grid
Selenium Driver Java Version installation method
Download Selenium-java-2.44.0.zip compressed file and unzip to the current folder, unpack and open
Download Selenium-java-client-driver-1.0.2.jar
Downloa
Since the launch of the Selenium+webdriver, the learning UI level of automated testing has a lot of convenience, learning curve and difficulty are reduced, at least the introduction is relatively simple, basically understand the point of Java development, the HTML structure to understand the people should be relatively easy to get started.Talk less, start now. Whether it is learning or practical, the first
the element you want to find. Take a look at the following animated demo
Method Three: Mouse over the UI element you want, click the right mouse button, select the Inspect Element menu command
We can also use Chrome to get the XPath of the element directly.
Internet Explorer or Edge
Microsoft's own browser also comes with "developer tools," Using the Tools menu or F12 to launch
Firefox's Firebug Plugin
Firefox is the best browser suppor
attribute value of the ID driver.findelement (by.cssselector ("img[alt= ' img1 '][href= ' http://www.sougou.com ']");6. Use the class name to locateDriver.findelement (By.classname ("Page's class attribute value"));Driver.findelement (By.classname ("tight left");//To write full7. Use tag name to locateDriver.findelement (by.tagname ("HTML tag name of the page"));webelement element = Driver.findelement (By.tagname ("a"));list8. Using the JS expression((Javascriptexecutor) driver). Executescript
Addbutton.click ();
Determine if the button is enable
addbutton.isenabled ();
Drop-down selection box (select)
Action of the Drop-down selection box
Find the element
Select select = New Select (Driver.findelement (by.id ("Proadditem_kind")));
Select the corresponding selection, index
Select.selectbyindex (2) starting from 0;
Select.selectbyvalue ("a");
Select.selectbyvisibletext ("kind AA");
Get all the options
list
Radio buttons (Radio bu
Summary of--selenium Learning in automated testingFirst, the concept and significance of automated testing:1. What is automated testing:Generally refers to the automation of software testing, software testing is to run the system or application under the preset conditions, evaluate the results of the operation, pre-conditions should include normal conditions and abnormal conditions.2. Meaning:Make testing more efficient, take advantage of more free ti
Selenium+java: Gets the value in the list(2011-08-23 17:14:48)
Tags: gossip
Category: Selenium
A preliminary study using the JAVA+TESTNG framework to write selenium test cases today learned several APIs:(1) Get the values from the list on the
Selenium webdriver Automated test Design (Webdriver Automation architecture design, definition interface, log processing, Java robot class applications)For you to share a set of courses, interested can add me 2748165793For more free information, you can view Http://blog.sina.com.cn/sonyandnokiaThe happy paradise of the yard farmCourse Outline1th Chapter:Introduction to the course overviewSelenium Introducti
Selenium is very helpful for our web automation testing, if we want to carry out a wide range of test coverage, we can not only run on one or two machines, the same selenium-grid also provide us with such help, We can easily build a distributed test environment with Selenium-grid. Unlike some of the other common distributed programs "such as: Hudson",
the action to get the page element, click the button, and enter the form.the Selenium offers 8 positioning methods:
Id
Name
Class name
Tag name
Link text
Partial link text
Xpath
CSS Selector
here are the 8 ways to locate in the code:
Findelement (By.id ())
Findelement (By.name ())
Findelement (By.classname ())
Findelement (By.tagname ())
Fi
= driver.findelement (By.id ("Father")). Findelement (Bylinktext ("xxx"));4. NosuchelementfoundexceptionThe Findelement () and findelements () methods throw the exception when the corresponding element is not found.Findelements:Selenium Webdriver's Findelements () method allows you to get a collection of specified rules for situations where you need to operate on a similar set of elements.Example: Verify the number of Baidu home navigation links and print out their hyperlink addressImplementati
parameter format requirement) -String size =string.valueof (Links.size ()); + //String size = integer.tostring (Links.size ()); A //String size = links.size () + ""; at //Verify the number of links -Selenesetestnghelper.assertequals ("8", size); - - //Print href attribute - //get all the elements in the list through a for loop, and then call the GetAttribute () method to get the attributes of the element - for(inti=0; I){ inSystem.out.pr
调试十分困难。 Because the page may have a lazy load situation. Although the page has been rendered, there may be ajx lazy loading. Some elements need to wait until the AJAX call is complete before they can be displayed. At this point, you need to add a wait mechanism on the page./** * 用于等待某个元素出现,软等待 * @param by */public boolean wait(final By by){ new WebDriverWait(driver, 10).until(new ExpectedConditionFor example, you want to find an element that id= "name":if (wait(By.id("name"))) xxx;else
Test courses at school, access to automated management tools, and work with teaching assistants to change jobs, so think about learning selenium, a powerful web automation tool.1.lenium official website: http://www.seleniumhq.org/Download the Selenium installation package here, I downloaded the selenium-java-3.8.0. The
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:
[email protected]
and provide relevant evidence. A staff member will contact you within 5 working days.