Read about selenium webdriver tutorials with java, The latest news, videos, and discussion topics about selenium webdriver tutorials with java from alibabacloud.com
How to handle popup windows in SeleniumRead CataloguePrincipleIn the code, through setTo get a handle to all pop-up browsers, and then traverse through, using the Swithcto.window (Newwindow_handle) method. You can navigate to the new window.HTML of the test pageHTML>Head> title>Common Web UI element operations, and API usagetitle> Scripttype= "Text/javascript"> functionOpen_win () {window.open ("http://www.cnblogs.com") } Script>Head>Body> form> inputtype=buttonv
1. JDK2.eclipse+testng>TESTNG installation.Name:testng Location:http://beust.com/eclipse.3.selenium WebdriverDownload Selenium Webdriver jar Package http://docs.seleniumhq.org/download/Selenium official website> Unzip when the download is complete.> Create a Java Project in
What is an IFRAMEAn IFRAME is an HTML that is used for Web page nesting. A Web page can be nested in another Web page and can nest many layers.A method for entering an IFRAME is provided in the seleniumEnter the ID called Framea of Iframedr.switchto (). FRAME ("Framea");Back to main window Dr.switchto (). Defaultcontent ();Main.htmlFrame.htmlSelenium code public static void Testiframe (Webdriver driver) { driver.get ("E:\\stashfolder\\[em
BufferedReader class to read the fileString s = null; while ((s = br.readline ()) =null) {//Use the ReadLine method to read one line at a timeresult = result + "\ n" +s;}Br.close ();}catch(Exception e) {E.printstacktrace ();}return result;}Main method invocationFile File = new file ("C:/a.txt");//Read filesSystem. out. println (txt2string(file) + "a");The problem: The orc recognition rate is still very low, the chance of login success has not exceeded 90%, need to improveSolution: Train the Orc
be customized for more complex page-waiting conditions
Condition of waiting
Webdriver method
Whether page elements are available on the page and can be clicked
Elementtobeclickable (by Locator)
The page element is in the selected state
Elementtobeselected (webelement Element)
Page elements exist in the page
Presenceofelementlocated (by Locator)
Whether to includ
protected]\\stash\\tank-moneyproject\\ Pudong Software Park Training center \ \ My Textbook \\Selenium webdriver\\frame\\ Main.html "); //at the time of the main windowDriver.findelement (By.id ("Maininput")). SendKeys ("main input"); //when the IFRAME is not entered, the following statement will error//driver.findelement (by.id ("Iframeinput")). SendKeys ("iframe input ");Driver.switchto (). FRAME ("Frame
); - //determine if alert is present in the page - NewWebdriverwait (driver,5). Until (Expectedconditions.alertispresent ()); the //--------------------Custom Judging Criteria----------------------------- -webdriverwait wait =NewWebdriverwait (Driver, 3);WuyiWait.until (NewExpectedcondition() { the PublicBoolean Apply (Webdriver webdriver) { - return!dr
The previously written automated test framework (PageObject design idea) has always been to execute a use case, start a browser driver to open a browser, a use case after the end of the browser close. This is not only a waste of time, but it is also a waste of resources to restart and close chromedriver.exe every time. This function is realized by making a little change to the relevant methods according to the order of execution of each annotation in the testng life cycle.First look at the Pagef
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 ())
Findelement (By.linktext ())
Findelement (B
visibleExpectedconditions.invisibilityofelementlocated (By.xpath ("//*[@id = ' kw ']")); //determine if the element can be clickedExpectedconditions.elementtobeclickable (By.xpath ("//*[@id = ' kw ']")); //wait for an element to be removed from the DOMExpectedconditions.stalenessof (Driver.findelement (By.xpath ("//*[@id = ' kw ']"))); //determines whether an element is selected and is typically used in a drop-down listExpectedconditions.elementtobeselected (By.xpath ("//*[@id = ' kw ']")); //d
). Build (). Perform ();d river.findelement (By.linktext ("Logout")). Click (); @AfterClasspublic void Quit () {driver.close ();}}Testng.xmlFINAL project structure looks like below,Parallel execution in TestNGAfter creating XML file as shown above, in next step, we'll execute the parallel test. Below is the code.1) thread-count: This is used for parallel execution and based on the number script. It'll execute in parallel or sequential order.2) verbose: It is used to log the execution details in
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.