"Automation __gui Automation" __java__selenium__ assertion __ Table header content Assertion

Source: Internet
Author: User
Tags gettext stub xpath

One, the code is as follows
Package Www.gui.v1;import Java.io.ioexception;import Java.util.concurrent.timeunit;import org.openqa.selenium.By; Import Org.openqa.selenium.webdriver;import Org.openqa.selenium.webelement;import Org.openqa.selenium.firefox.firefoxdriver;import Org.openqa.selenium.interactions.actions;public class ab__Gui__ DUANYAN__V1 {webdriver driver= null; Actions actions= null;public static void Main (string[] args) {//TODO auto-generated method STUBAB__GUI__DUANYAN__V1 gd= N EW AB__GUI__DUANYAN__V1 (); Gd.init ();//gd.killdo (); gd.tableprocess ();} private void Init () {//Todo auto-generated method stub//Todo auto-generated method stub//system.setproperty ("Webdriver. Firefox.bin "," d:\\mozilla//Firefox\\firefox.exe "); System.setproperty ("Webdriver.firefox.bin", "D:\\firefox__37\\firefox.exe"); this.driver = new Firefoxdriver ();// Start Firefox this.driver.manage (). Timeouts (). implicitlywait (timeunit.seconds);//Element wait time This.driver.manage (). Timeouts (). Pageloadtimeout (timeunit.seconds);//page load time This.driver.manAge (). Timeouts (). Setscripttimeout (timeunit.seconds);//Ajax Request This.driver.manage (). window (). Maximize ();// This.driver.get ("https://www.baidu.com/");//Open the URL in the browser actions = new actions (driver);} private void Killdo () {//TODO auto-generated method Stubthis.driver.get ("http://localhost/Agileone/"); try { Thread.Sleep (3000);} catch (Interruptedexception E1) {e1.printstacktrace ();} try {runtime.getruntime (). EXEC ("taskkill/f/im Firefox.exe");} catch (IOException e) {e.printstacktrace ();}} private void Tableprocess () {//TODO auto-generated method Stubthis.driver.get ("http://localhost/Agileone/"); This.driver.findElement (By.id ("username")). SendKeys ("admin"); This.driver.findElement (by.id ("password")). SendKeys ("admin"); This.driver.findElement (by.id ("Login")). Click (); This.driver.findElement (By.partiallinktext (" Demand proposal "). Click (); This.driver.findElement (By.id (" headline ")). SendKeys (" Wjb__3 "); This.driver.findElement ( By.classname ("Ke-common-icon")). Click (); This.driver.findElement (By.classname ("Ke-textarEA "). SendKeys (" DD "); This.driver.findElement (By.id (" Add ")). Click (); try {thread.sleep (+);} catch ( Interruptedexception E1) {e1.printstacktrace ();} Webelement table= this.driver.findElement (By.xpath ("//table[@id = ' dataTable ']");//system.out.println ( Table.gettext ()); Webelement tr1= this.driver.findElement (By.xpath ("//table[@id = ' dataTable ']/tbody/tr");//system.out.println ( Tr.gettext ()); Webelement tr3= this.driver.findElement (By.xpath ("//table[@id = ' dataTable ']/tbody/tr[3]");//system.out.println ( Tr3.gettext ()); Webelement tr1con2= this.driver.findElement (By.xpath ("//table[@id = ' dataTable ']/tbody/tr[1]/td[2]"); System.out.println (Tr1con2.gettext ());}}

  

"Automation __gui Automation" __java__selenium__ assertion __ Table header content Assertion

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.