Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Login {
- public static WebDriver driver;
- String username = "username";
- String password = "password";
- String baseurl = "http://mybusiness.com/login.aspx";
- public class Details {
- @Test(priority = 0)
- public void loginpage() {
- //WebDriver driver = new FirefoxDriver();
- System.setProperty("webdriver.chrome.driver","D:\From H\Selenium Package\ChromeDriver\chromedriver_win32\chromedriver.exe");
- DesiredCapabilities capabilities = DesiredCapabilities.chrome();
- capabilities.setCapability("chrome.switches", Arrays.asList("--incognito"));
- ChromeOptions options = new ChromeOptions();
- options.addArguments("--test-type");
- options.addArguments("--disable-extensions");
- capabilities.setCapability("chrome.binary","D:\From H\Selenium Package\ChromeDriver\chromedriver_win32\chromedriver.exe");
- capabilities.setCapability(ChromeOptions.CAPABILITY, options);
- driver = new ChromeDriver(capabilities);
- driver.manage().deleteAllCookies();
- driver.manage().window().maximize();
- driver.get(baseurl);
- try {
- Thread.sleep(10000); // 1000 milliseconds is one second.
- } catch (InterruptedException ex) {
- Thread.currentThread().interrupt();
- }
- WebElement username = driver.findElement(By.id("UserName"));
- username.sendKeys(username);
- try {
- Thread.sleep(10000); // 1000 milliseconds is one second.
- } catch (InterruptedException ex) {
- Thread.currentThread().interrupt();
- }
- WebElement password = driver.findElement(By.id("Password"));
- password.sendKeys(password);
- try {
- Thread.sleep(10000);
- } catch (InterruptedException ex) {
- Thread.currentThread().interrupt();
- }
- WebElement button = driver.findElement(By.id("ButtonClick"));
- button.click();
- try {
- Thread.sleep(10000);
- } catch (InterruptedException ex) {
- Thread.currentThread().interrupt();
- }
- }
- // Selecting a date from date picker
- @Test(priority = 1)
- public void RecordSearch() {
- WebElement calendar = driver.findElement(By.id("CalendarId"));
- calendar.click();
- try {
- Thread.sleep(5000); // 1000 milliseconds is one second.
- } catch (InterruptedException ex) {
- Thread.currentThread().interrupt();
- }
- WebElement month = driver.findElement(By.xpath("XPath"));
- month.click();
- try {
- Thread.sleep(5000); // 1000 milliseconds is one second.
- } catch (InterruptedException ex) {
- Thread.currentThread().interrupt();
- }
- WebElement day = driver.findElement(By.xpath("XPath"));
- day.click();
- try {
- Thread.sleep(5000); // 1000 milliseconds is one second.
- } catch (InterruptedException ex) {
- Thread.currentThread().interrupt();
- }
- WebElement submit = driver.findElement(By.id("Submit"));
- submit.click();
- try {
- Thread.sleep(10000); // 1000 milliseconds is one second.
- } catch (InterruptedException ex) {
- Thread.currentThread().interrupt();
- }
- }
- driver.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement