1.driver.get(); = To get some website into browser.
2.driver.manage().window().maximize(); = to maximize the browser.
3.driver.manage().window().fullscreen();= to full the entire browser screen.
4.
Dimension d = new Dimension(width,height);
driver.manage.window.setsize();
5.driver.FindElement(); = to find the element.
6.click();
7.id();
8.name();
9.sendKeys();
driver.findElement(By.id("input-password")).sendKeys(Keys.ENTER);= for keyboard
key action
10.classname();
11.linkText();
12.cssselector();
13.Partiallinktext();
14.Clear();
15.getText();
String text = driver.findElement(By.id("pah")).getText();
System.out.println(text);
16.getTitle();
String title = driver.getTitle();
System.out.println(title);
17.getCurrentUrl();
String url = driver.getCurrentUrl();
System.out.println(url);
18.close();
19.quit();
20.getAttribute();
String textOnButton =
driver.findElement(By.xpath("//*[@id=\"BlogSearch1_form\"]/form/table/tbody/tr/
td[2]/input")).getAttribute("value");
System.out.println(textOnButton);
21.isDisplayed();
System.out.println(driver.findElement(By.xpath("//input[@class='gsc-search-
button'][@type='submit']")).isDisplayed());
22.isEnabled();
System.out.println(driver.findElement(By.id("but2")).isEnabled());
23.isSelected();
System.out.println(driver.findElement(By.id("checkbox1")).isSelected());
24.getScreenshotAs();
File srcScreenshot =
driver.findElement(By.name("search")).getScreenshotAs(OutputType.FILE);
FileHandler.copy(srcScreenshot, new
File(System.getProperty("user.dir")+"\\screenshot.png"));
25.getPageSource();
String pageGetSource = driver.getPageSource();
System.out.println(pageGetSource);
26.navigate();
27.submit();
driver.findElement(By.id("input-email")).sendKeys("arun.selenium@gmail.com");
Thread.sleep(5000);
driver.findElement(By.id("input-password")).sendKeys("Second@123");
Thread.sleep(5000);
driver.findElement(By.id("input-password")).submit();
28.getTagName();
String tagName = driver.findElement(By.id("alert1")).getTagName();
System.out.println(tagName);
29.getSize();
org.openqa.selenium.Dimension dimension =
driver.findElement(By.name("search")).getSize();
System.out.println("Height of the search box field
is :"+dimension.height);
System.out.println("Width of the search box field
is :"+dimension.width);
driver.quit();
30.getLocation();
Point point = driver.findElement(By.id("alert1")).getLocation();
System.out.println("X coordinate area of the button is :"+point.x);
System.out.println("Y coordinate area of the button is :"+point.y);
31.xPath();
driver.findElement(By.xpath("//button[@type='button'][@class='btn btn-default
btn-lg']")).click();
32.findElements();
List<WebElement> elements = driver.findElements(By.xpath("//button"));
for(WebElement element:elements) {
System.out.println(element.getText());
}
33.tagName();
List<WebElement> elements = driver.findElements(By.tagName("button"));
for(WebElement element : elements) {
System.out.println(element.getText());
}
34.getCSSValue();
String lineheightForHomeOption =
driver.findElement(By.id("home")).getCssValue("line-height");
System.out.println(lineheightForHomeOption);
driver.quit();
35.getClass();
String driverObjectReferenceClass = driver.getClass().getSimpleName();
System.out.println(driverObjectReferenceClass);
driver.quit();
36.getWindowHandle(),getWindowHandles,switchTo(),window();
String firstWindow = driver.getWindowHandle();
Thread.sleep(5000);
driver.findElement(By.linkText("Open a popup window")).click();
Thread.sleep(5000);
Set<String> windows = driver.getWindowHandles();
Iterator<String> itr = windows.iterator();
while(itr.hasNext()) {
String window = itr.next();
driver.switchTo().window(window);
if(driver.getTitle().equals("Basic Web Page Title")) {
driver.close();
}
}
driver.switchTo().window(firstWindow);
driver.findElement(By.name("q")).sendKeys("Abdul Shaikh");
37.selectByVisibleText(); for dropdownboxfield
WebElement dropdownField = driver.findElement(By.id("drop1"));
Select select = new Select(dropdownField);
select.selectByVisibleText("doc 3");
38.selectByIndex();
WebElement dropdownField = driver.findElement(By.id("drop1"));
Select select = new Select();
select.selectByIndex(1);
39.selectByValue();
WebElement dropdownField = driver.findElement(By.id("drop1"));
Select select = new Select();
select.selectByValue();
40.isMultiple();
WebElement dropdownField = driver.findElement(By.id("drop1"));
Select select = new Select();
System.out.println(select.isMultiple);
41.frame();
WebElement frameOfChapter3 = driver.findElement(By.id("iframe2"));
driver.switchTo().frame(frameOfChapter3);
driver.findElement(By.linkText("Chapter3")).click();
42.parentFrame();
driver.switchTo().frame("");
driver.switchTo().frame(0);
String textInsideBlueBox =
driver.findElement(By.xpath("//h1")).getText();
System.out.println(textInsideBlueBox);
driver.quit();
43.defaultContent();
44.pageLoadTimeout();
driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
45.setScriptTimeout();
driver.manage().timeouts().setScriptTimeout(10, TimeUnit.SECONDS);
46.implicitlyWait();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
47.until and visibilityOfElementLocated();
//WebDriverWait wait = new WebDriverWait(driver,10);
//driver.findElement(By.className("dropbtn")).click();
//wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("Facebook
")));
//driver.findElement(By.linkText("Facebook")).click();
48.elementToBeClickable();
driver.findElement(By.xpath("//
button[@onclick='setTimeout(myFunctionAXD,10000)']")).click();
wait.until(ExpectedConditions.elementToBeClickable(By.id("dte")));
driver.findElement(By.id("dte")).click();
49.invisibilityOfElementLocated();
WebDriverWait wait = new WebDriverWait(driver,25);
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("deletesuccess"
)));
driver.findElement(By.id("alert2")).click();
50.alert(),getText(),accept(),dismiss();
driver.findElement(By.id("alert1")).click();
Thread.sleep(5000);
Alert alert = driver.switchTo().alert();
String textOnAlert = alert.getText();
System.out.println(textOnAlert);
Thread.sleep(5000);
alert.accept();
driver.quit();
51.alertIsPresent();
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();
alert.accept();
52.sendKeys() Command of Alert interface
//driver.findElement(By.id("prompt")).click();
//Thread.sleep(5000);
//Alert alert = driver.switchTo().alert();
//Thread.sleep(5000);
//alert.sendKeys("Abdul Shaikh");
53.moveToElement();
WebElement blogsMenu = driver.findElement(By.id("blogsmenu"));
Actions actions = new Actions(driver);
actions.moveToElement(blogsMenu).build().perform();
54.click() Command of Action class
WebElement clickToGetAlertButton = driver.findElement(By.id("alert1"));
Actions actions = new Actions(driver);
actions.moveToElement(clickToGetAlertButton).click().build().perform();
55.dragAndDropBy()
WebElement minOption = driver.findElement(By.xpath("//a[@aria-labelledby='price-
min-label']"));
Actions actions = new Actions(driver);
actions.dragAndDropBy(minOption, 200, 0).build().perform();
56.contextClick(); it is mouse right click.
WebElement searchBoxField = driver.findElement(By.name("q"));
Actions actions = new Actions(driver);
actions.contextClick(searchBoxField).build().perform();
57.switchTo()
58.executeScript()
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("alert('Abdul Shaikh');");
59.executeAsyncScript()
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeAsyncScript("window.setTimeout(function()
{alert('world');},4000);alert('Hello);");
60.getCookies()
Set<Cookie> cookies = driver.manage().getCookies();
for(Cookie cookie : cookies) {
System.out.println("Cookie Name :"+cookie.getName());
System.out.println("Cookie Value :"+cookie.getValue());
System.out.println("Cookie Path :"+cookie.getPath());
System.out.println("Cookie Domain :"+cookie.getDomain());
System.out.println("Cookie ExpiryDate : "+cookie.getExpiry());
System.out.println("------------------------------------");
}
61.getCookieNamed()
Cookie cookie = driver.manage().getCookieNamed("OCSESSID");
System.out.println("Cookie Name :"+cookie.getName());
System.out.println("Cookie Value :"+cookie.getValue());
System.out.println("Cookie Domain :"+cookie.getDomain());
System.out.println("Cookie Path :"+cookie.getPath());
System.out.println("Cookie Expiry Date :"+cookie.getExpiry());
62.addCookie()
Cookie cookie = new Cookie("abdul", "Shaikh");
driver.manage().addCookie(cookie);
63.deleteCookieNamed()
driver.manage().deleteCookieNamed("OCSESSID");
64.deleteCookie()
Cookie cookie = driver.manage().getCookieNamed("OCSESSID");
driver.manage().deleteCookie(cookie);