Selenium is one of the most widely used open source Web UI (User Interface) automation testing suite.
It was originally developed by Jason Huggins in 2004 as an internal tool at Thought Works.
Selenium supports automation across different browsers, platforms and programming languages.
Selenium automates browsers. That's it!
What you do with that power is entirely up to you
Primarily it is for automating web applications for testing purposes, but is certainly not limited to just that
Boring web-based administration tasks can (and should) also be automated as well
WebDriver driver = new ChromeDriver();
WebDriver driver = new FirefoxDriver();
WebDriver driver = new InternetExplorerDriver();
WebDriver driver = new EdgeDriver();
WebDriver driver = new SafariDriver();
WebDriver driver = new HtmlUnitDriver();
driver.findElement(By.id("Id Value"));
driver.findElement(By.name("Name Value"));
driver.findElement(By.className("Class Name Value"));
driver.findElement(By.linkText("Link text Value"));
driver.findElement(By.partialLinkText("Partial Text Constant Value"));
driver.findElement(By.tagName("Tag Name Value"));
driver.findElement(By.cssSelector("CSS Value"));
driver.findElement(By.xpath("Xpath Value"));
driver.findElement(with(By.tagName("input")).above(passwordField));
driver.findElement(with(By.tagName("input")).below(emailAddressField));
driver.findElement(with(By.tagName("button")).toLeftOf(submitButton));
driver.findElement(with(By.tagName("button")).toRightOf(submitButton));
driver.findElement(with(By.tagName("input")).near(emailAddressLabel));
driver.findElement(new ByAll(By.className("ElementClassName"),By.id("Element Id"), By.name("Element Name")))
WebElement element =driver.FindElement(By.ElementLocator("Value of Element Locator"));
element.click();
element.sendKeys("Input Text");
element.clear();
element.submit();
element.getAttribute(“type”);
String innerText = element.getText();
boolean enabledstatus = element.isEnabled();
boolean displayedstatus = element.isDisplayed();
boolean selectedstatus = element.isSelected();
Select select = new Select(element);
select.selectByIndex(Integer Index);
select.selectByVisibleText("Text");
select.SelectByValue("Value");
select.deselectAll();
select.deselectByIndex(Integer Index);
select.deselectByVisibleText("Text");
select.deselectByValue("Value");
WebElement selectedOptions = select.getOptions();
String pageTitle = driver.getTitle();
String currentURL = getCurrentUrl();
String currentPageSource = driver.getPageSource();
driver.get("https://www.facebook.com/");
driver.manage().window().maximize();
driver.manage().window().fullscreen();
driver.navigate().to("https://www.google.com/");
driver.navigate().back();
driver.navigate().forward();
driver.navigate().refresh();
driver.close();
driver.quit();
Alert alert = driver.switchTo().alert();
alert.accept();
alert.dismiss();
alert.getText();
alert.sendKeys(“Input Data");
Cookie cookie = new Cookie(“cookieName”, “cookieValue”);
driver.manage().addCookie(cookie);
driver.manage().getCookies();
driver.manage().getCookieNamed(arg0);
driver.manage().deleteAllCookies();
driver.manage().deleteCookieNamed(arg0);
driver.switchTo().frame(int Frame Index);
driver.switchTo().frame("frameName");
WebElement element =driver.FindElement(By.ElementLocator("Value of Element Locator"));
driver.switchTo().frame(element);
driver.SwitchTo().defaultContent();
TakesScreenshot screenshot =((TakesScreenshot)driver);
File srcFile= screenshot.getScreenshotAs(OutputType.FILE);
FileHandler.copy(srcFile, destFile);
Actions action = new Actions(driver);
action.keyDown(Keys.CONTROL);
action.keyUp(Keys.CONTROL);
action.clickAndHold(webElement).build().perform();
action.doubleClick(webElement).build().perform();
action.moveToElement(webElement).build().perform();
action.moveByOffset(xOffset,yOffset).build().perform();
action.dragAndDrop(sourceEle,targetEle).build().perform();
action.release().build().perform();
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
welement = wait.until(Syntax: WebDriverWait wait = new WebDriverWait(driver, timeout);
ExpectedConditions.elementToBeClickable(locator));
welement.click();
driver.manage().timeouts().pageLoadTimeout(30,TimeUnit.SECONDS);
WebElement element =driver.FindElement(By.ElementLocator("Value of ElementLocator"));
element.sendKeys(filePath);
String handle=driver.getWindowHandle();
Set handles = getWindowHandles();
driver.switchTo().window(handle);
##Capture Width and Height of an Element
Point point = element.getLocation();
int elementWidth = element.getSize().getWidth();
int elementHeight = element.getSize().getHeight();
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("window.scrollBy(0,100)");
js.executeScript("window.scrollTo(0,
document.body.scrollHeight)");
WebElement element =driver.FindEle
ment(By.ElementLocator("Value of Element Locator"));
js. executeScript("arguments[0].scrollIntoView()", element);
##Selenium
You're sections headers will be used to reference location of destination.
Selenium is the best automation tool for web testing. In this project you wil learn from scratch to advanced level of concect which had in selenium.
- Java
- Selenium WebDriver
- Eclipse(IDE)
<p>dummy code</p>
MIT License
Copyright (c) [2017] [James Q Quick]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- Twitter - @jamesqquick
- Website - James Q Quick