C- SELENIUM
C- SELENIUM
Advantages of Selenium:
Disadvantages of Selenium:
Dynamic Xpath -:
Methods of SearchContext-:
o findElement(), FindElements(By.arg)
Methods of WebDriver-:
o Close(), get(), getCurrentUrl(), getPageSource(),
getTitle(), getWindowHandle(),
getWindowHandles(), manage(), navigate(), quit(),
switchTo()
Methods of JavaScriptExecutor-:
o executeAsyncScript(), executeScript()
Method of TakesScreenshot-:
o getScreenshotAs()
Method of WebElement-:
Clear(), click(), getAttribute(), getCssValue(),
getLocation(), getRect(), getSize(), getTagName(),
getText(), isDisplayed(), isEnabled(), isSelected(),
sendkeys(), submit()
element.getLocation().getX();
element.getLocation().getY();
Using Selenium, we can execute JavaScript code to set a value in an input field.
driver.switchTo().frame(0);
driver.switchTo().defaultContent();
driver.switchTo().parentFrame();
wb.getSheet(sheetName).sh.getRow(1).getCell(1).setCellValue(“Hi”);
FileOutputStream fos = new FileOutputStream(FILE_PATH);
wb.write(fos);
wb.close();
************File Upload************
public void selectFileToUpload(WebElement fileInputElement)
{
File file = new File("./TestData/Jiviews Team.jpg");
String absolutePath = file.getAbsolutePath();
fileInputElement.sendKeys(absolutePath);
}
Q. How to take screenshot
wait.until(ExpectedConditions.elementToBeClickable(locator));
wait.until(ExpectedConditions.elementToBeSelected(locator));
wait.until(ExpectedConditions.visibilityOf((locator));
wait.until(ExpectedConditions.invisibilityOf(locator));
wait.until(ExpectedConditions.presenceOfElementLocated(locator));
Boolean titleContains = wait.until(ExpectedConditions.titleContains("page
Title"));
Boolean title = wait.until(ExpectedConditions.titleIs("exact_title"));
Alert alert = wait.until(ExpectedConditions.alertIsPresent());
Boolean textPresent =
wait.until(ExpectedConditions.textToBePresentInElementLocated(locator,
"expected_text"));
ImplicitWait-:
We do not specify the waiting condition explicitly.
We can handle the synchronization of all the findElement &
findElements method.
After the duration we get NoSuchElementException.
Time duration can be days, hours, mins, seconds etc.
ExplicitWait-:
We should specify the waiting condition explicitly.
We can handle the synchronization o any method but only one at a
time.
After the duration we get TimeOutException.
Time duration will be only seconds.
select.selectByIndex(1);
select.selectByValue("value");
select.selectByVisibleText("visible Text");
select.deselectByIndex(0);
select.deselectByValue("value");
select.deselectByVisibleText("visible Text");
select.deselectAll();
select.getOptions();
select.getAllSelectedOptions();
select.getFirstSelectedOption();
FindElements-: