Java examples for HTML:selenium
Use selenium ChromeDriver to click links
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.safari.SafariDriver; import com.sun.org.apache.bcel.internal.generic.Select; // import com.sun.org.apache.bcel.internal.generic.Select; public class Appeals { public static void main(String[] args) throws InterruptedException { // TODO Auto-generated method stub try {/* w w w . ja v a2 s. c om*/ System.setProperty("webdriver.chrome.driver", "/Users/abc/Documents/workspace/MSD-Assign4/chromedriver"); WebDriver myChromeDriver = new ChromeDriver(); myChromeDriver.get("http://your server.com"); Thread.sleep(500); myChromeDriver.findElement(By.linkText("Login")).click(); Thread.sleep(500); myChromeDriver.findElement(By.name("email")).sendKeys("admin@email.com"); Thread.sleep(500); myChromeDriver.findElement(By.name("password")).sendKeys("password"); Thread.sleep(500); myChromeDriver.findElement(By.cssSelector("button.btn.btn-primary")).click(); Thread.sleep(500); myChromeDriver.navigate().to("http://your url.com/appeals"); Thread.sleep(500); myChromeDriver.findElement(By.linkText("Create Appeal")).click(); Thread.sleep(500); myChromeDriver.findElement(By.name("description")).sendKeys("Old Books for sale"); Thread.sleep(500); myChromeDriver.findElement(By.name("start_date_time")).sendKeys("05/01/2019 9:00 AM"); Thread.sleep(500); myChromeDriver.findElement(By.name("type")).sendKeys("Email"); Thread.sleep(500); myChromeDriver.findElement(By.xpath("//input[@value='Save']")).click(); Thread.sleep(500); myChromeDriver.findElement(By.xpath("(//a[contains(text(),'View')])[1]")).click(); Thread.sleep(500); myChromeDriver.findElement(By.linkText("Librarian Tools")).click(); Thread.sleep(500); myChromeDriver.findElement(By.xpath("(//input[@value='Delete'])[3]")).click(); Thread.sleep(500); myChromeDriver.findElement(By.linkText("Admin")).click(); Thread.sleep(500); myChromeDriver.findElement(By.linkText("Logout")).click(); // myChromeDriver.quit(); } catch (Exception e) { System.out.println("Error:" + e.getMessage()); } } }