Professional Documents
Culture Documents
package sample1;
import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import javax.imageio.ImageIO;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.io.FileHandler;
import org.testng.annotations.Test;
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.get("http://demo.automationtesting.in/AutoComplete.html");
Thread.sleep(3000);
driver.close();
}
}
package sample1;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.get("http://www.leafground.com/pages/Calendar.html");
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("document.getElementById('datepicker').value='12/20/2021'");
Thread.sleep(2000);
driver.close();
}
}
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.get("https://www.w3schools.com/howto/howto_css_custom_scrollbar.asp");
WebElement el = driver.findElement(By.xpath("//a[contains(text(),'Hide
Scrollbar')]"));
JavascriptExecutor jse1 = (JavascriptExecutor) driver;
jse1.executeScript("arguments[0].scrollIntoView(true);",el);
Thread.sleep(3000);
driver.close();
}
}
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.testng.annotations.Test;
package functionality;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.PageFactory;
import org.testng.annotations.Test;
import object_repository.Elements1;
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.get("https://wf24.myhcl.com/iTime/iTime/index.html?v=35#/TimeSheet");
Elements1.Timecell(driver).sendKeys("09:00");
Elements1.Savebutton(driver).click();
}
}
package object_repository;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.testng.annotations.Test;
@FindBy(xpath="//input[@type='text']")
public static WebElement Timecell;
@FindBy(id="le_apply")
public static WebElement Savebutton;
}
*****************************************************************
package functionality;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.PageFactory;
import org.testng.annotations.Test;
import object_repository.Elements;
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.get("https://wf24.myhcl.com/iTime/iTime/index.html?v=35#/TimeSheet");
PageFactory.initElements(driver,Elements.class);
Elements.Timecell.sendKeys("09:00");
Elements.Savebutton.click();
}
}
package object_repository;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.testng.annotations.Test;
@FindBy(id="userName")
public static WebElement username;
@FindBy(id="password")
public static WebElement password;
@FindBy(id="submitBtn")
public static WebElement btn;
}
=====================================
package datadriven;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.PageFactory;
import org.testng.annotations.Test;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import object_repository.Elements;
@Test
public void f() throws BiffException, IOException, InterruptedException {
System.setProperty("webdriver.chrome.driver", "D:\\New folder\\
chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.get("https://ksrtc.in/oprs-web/login/show.do");
}
driver.close();
}}