WebDriver driver; public Login(String UserName,String BrandName) { driver=new InternetExplorerDriver(); driver.findElement(By.xpath("//input[@name='UserNameInputText']")).sendKeys(UserName); driver.findElement(By.xpath("//input[@name='Brand']")).sendKeys(BrandName); driver.findElement(By.xpath("//input[@name='CmdLogin']")).click(); String Title=driver.getTitle(); if(!Title.contains("VSS 4.0")) { System.out.println(UserName+""+"does not exists"); driver.quit(); } CheckForCancel(); } private void CheckForCancel() { if(!driver.findElements(By.id("Cancel")).isEmpty()) { driver.findElement(By.id("Cancel")).click(); } }}
import lib.Login;
public class MessageBoard { void Initalisation() {
} public static void main(String[] args) { System.setProperty("webdriver.ie.driver", "C:\\Eclipse\\IEDriverServer.exe"); DesiredCapabilities capability=new DesiredCapabilities(); capability.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); InternetExplorerDriver driver=new InternetExplorerDriver(capability); Login login=new Login("TYP40FI","Volvo"); }
}
driver.findElement(By.xpath("//input[@name='UserNameInput']").sendKeys(UserName);