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