1. First install the JDK, the recommended installation is the JDK version is 1.72. Install the JDK steps:The first step:Step Two:Step Three:To configure the JDK environment variable, click My Computer-right-advanced-environment variable.Fifth Step:See if the JDK environment variable is installed successfully.Step: Enter in the DOS command line: Java and JavacOutput again: java-version: View
Many tests fail because clicking on an element fails or entering text in a field that is not visible, or entering text in a text that cannot be entered.We can check the status of the elements before we do the actual operation. The Webelement class provides such a method.
Method
Objective
IsEnabled ()
Checks whether the element is enabled (returns false only if the input element is set to disabled)
IsSelected ()
Check whether the eleme
1. Problems with certain selection buttons not being selected due to limitations on some pages of the pagea lot of times due to some restrictions on the page can cause us to not be able to use webdriver to achieve our manual normal operation, we can execute js to properly change the page style, For example, some selection boxes in the page display boundaries, because the reason for the display of the scroll bar while at the border when the click on the selection box is not a point can only drag
Expectedconditions.texttobepresentinelementlocated (By.xpath ("//*[@id = ' kw ']"), "Baidu"); 31//The element's Value property contains the characters in the argument String ExpectedcondItions.texttobepresentinelementvalue (By.xpath ("//*[@id = ' kw ']"), "* * *"), 33//Determine if the form can be cut past, you can cut past and return true, Otherwise put back False34 Expectedconditions.frametobeavailableandswitchtoit (by.id ("* *")); 35//Determine if an element does not exist in the DOM
This is a method that can be called directly in mainprivate static void ie () {Webdriver Driver;IE started successfully, files is to start IE driverSystem.setproperty ("Webdriver.ie.driver", "Files/iedriverserver.exe");Code off IE some configurationDesiredcapabilities DC = Desiredcapabilities.internetexplorer ();Dc.setcapability (Internetexplorerdriver.introduce_flakiness_by_ignoring_security_domains, true);Dc.setcapability ("Ignoreprotectedmodesettings", true);Load shutdown configuration into I
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
1. For array calls and parameters these are some of the basic understanding of automated testing that can greatly simplify our testing process, such as when conducting a login test, if you need to conduct multiple site testing, then using a two-dimensional array to test, for the simplification of the test code has played a significant role, Every thing as long as the right place can bring us some convenient, the following is the code I wrote, Welcome to guide:Publicvoidtestlogin1 () {//xxx repre
Package com.day.www;Import org.testng.annotations.AfterClass;Import org.testng.annotations.AfterMethod;Import org.testng.annotations.BeforeClass;Import org.testng.annotations.BeforeMethod;Import org.testng.annotations.Test;/** The plugin needs to be loaded before using Testng. Here's How:* Launch eclipse, Select "Install New software"* Click "Add" name:testng,* Location:http://beust.com/eclipse* complete, then click "ok"* Choose "select all" and "TestNG" and click "Next" to continue* Tick "Accep
]")); Emailimgvcode.click (); WaitTime (3000); //Get the Password check information node and determine when it exists and whether the information is "Password strength: High"Webelement Checkpassword = driver.findelement (By.cssselector ("[Class=password3]")); if(Checkpassword.isdisplayed () "Password strength: High". Equals (Checkpassword.gettext ())) { //after the password check is passed, get the authentication verification picture node and get the information of the
tool to compile scripts into executable files, which are compiled into. exe format Ii.. exe file written by AutoIt/** Upload Files* Normal upload: Normal attachment upload is the path of the local file as I a value in the input tag, the form form to submit this value to the server*/Define the upload function, the first parameter browser is the name of the browser, the second parameter filepath is the file pathpublic void Handleupload (String browser,string filePath) {Defines the path to the Au
XPath begins parsing from the root node of the documentThe relative path begins with "//" and allows the XPath to begin parsing from any element node of the documentRelative path Positioning methodIn the tested Web page, find the button in the first div tagAn XPath expressioninput[@value = "Query"]Webelement button = driver.findelement (By.xpath ("//input[@value = ' query ']");Using index numbers to locateIn the tested Web page, find the query button in the second div tagINPUT[2]Webelement butt
B_method () {System.out.println ("I-M in Method B");} @Test (priority=6) public void A_method () {System.out.println ("I-M in Method a");} @Test (priority=0) public void E_method () {System.out.println ("I-M in Method E");} @Test (priority=6) public void D_method () {System.out.println ("I-M in Method D");}}Output:I ' m in the method B I ' m in method C I ' m in method E I ' m in method A I ' m ' method D Passed:b_method passed:c_method PASSED: E_method Passed:a_method Passed:d_methodExplanatio
keep control of what is needed and where to wait, to control the waiting conditions more precisely.1 Public voidtestwithimplicitwait () {2System.setproperty ("Webdriver.chrome.driver", "Chromedriver.exe");3Webdriver Driver =Newchromedriver ();4Driver.get ("http://map.baidu.com");5 6Webelement curcity = driver.findelement (By.id ("Curcity"));7 Curcity.click ();8 9 //set wait time 10 secondsTenwebdriverwait wait =NewWebdriverwait (driver,10); One //wait until match element text conte
Public voiduploadfile (String path) {//File File = new file ("C:\\jacob-1.18-m2-x64.dll"); //System.setproperty (Libraryloader.jacob_dll_path, File.getabsolutepath ());//Add the DLL to the system variable. or throw it under the System32.AUTOITX x=NewAutoitx (); Locale Locale=Locale.getdefault (); String title= "Open"; String BrowserType=TestCase.DriverManager.browserType; if(Browsertype.equals ("CHROME")) { if(Locale.getdisplaylanguage (). Equals ("Chinese")) title = "Open"; if(X.winw
, and the jar files were maintained by CVS. So the Maven founders started MAVEN, a clear definition of the project, including a convenient way to publish project information, and a way to share jars across multiple projects.1featuresSo what's the difference between Maven and Ant? Before you answer this question, the first thing to emphasize is that
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.