- Saved searches
- Use saved searches to filter your results more quickly
- madhank93/selenium-cheatsheet-java
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- Selenium webdriver methods in java
- Uses of WebDriver in org.openqa.selenium.bidi
- Uses of WebDriver in org.openqa.selenium.bidi.browsingcontext
- Uses of WebDriver in org.openqa.selenium.chrome
- Uses of WebDriver in org.openqa.selenium.chromium
- Uses of WebDriver in org.openqa.selenium.devtools
- Uses of WebDriver in org.openqa.selenium.edge
- Uses of WebDriver in org.openqa.selenium.firefox
- Uses of WebDriver in org.openqa.selenium.grid.session.remote
- Uses of WebDriver in org.openqa.selenium.ie
- Uses of WebDriver in org.openqa.selenium.interactions
- Uses of WebDriver in org.openqa.selenium.logging
- Uses of WebDriver in org.openqa.selenium.remote
- Uses of WebDriver in org.openqa.selenium.safari
- Uses of WebDriver in org.openqa.selenium.support
- Uses of WebDriver in org.openqa.selenium.support.decorators
- Uses of WebDriver in org.openqa.selenium.support.events
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
A comprehensive list of selenium commands in Java
madhank93/selenium-cheatsheet-java
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
A curated list of selenium commands in Java
1. Browser property setup
System.setProperty(“webdriver.chrome.driver”, “/path/to/chromedriver”);
System.setProperty(“webdriver.gecko.driver”, “/path/to/geckodriver”);
System.setProperty(“webdriver.edge.driver”, “/path/to/MicrosoftWebDriver”);
2. Browser Initialization
WebDriver driver = new FirefoxDriver();
WebDriver driver = new ChromeDriver();
WebDriver driver = new InternetExplorerDriver();
WebDriver driver = new SafariDriver();
DesiredCapabilities caps = new DesiredCapabilities(); caps.setCapability(“browserName”, “chrome”); caps.setCapability(“browserVersion”, “80.0””); caps.setCapability(“platformName”, “win10”); WebDriver driver = new ChromeDriver(caps); // Pass the capabilities as an argument to the driver object
DesiredCapabilities caps = new DesiredCapabilities(); caps.setCapability(“browserName”, “firefox”); caps.setCapability(“browserVersion”, “81.0””); caps.setCapability(“platformName”, “win10”); WebDriver driver = new FirefoxDriver(caps); // Pass the capabilities as an argument to the driver object
ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setBinary("C:Program Files (x86)GoogleChromeApplicationchrome.exe"); // set if chrome is not in default location chromeOptions.addArguments("--headless"); // Passing single option chromeOptions.addArguments("--start-maximized", "--incognito","--disable-notifications" ); // Passing multiple options WebDriver driver = new ChromeDriver(chromeOptions); // Pass the capabilities as an argument to the driver object
FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.setBinary(new FirefoxBinary(new File("C:Program FilesMozilla Firefox irefox.exe"))); // set if chrome is not in default location firefoxOptions.setHeadless(true); WebDriver driver = new FirefoxDriver(caps); // Pass the capabilities as an argument to the driver object
- ChromeOptions/FirefoxOptions class — Recommended
- Or you can specify the capabilities directly as part of the DesiredCapabilities — its usage in Java is deprecated
driver.get(“http://google.com”) driver.navigate().to(“http://google.com”)
Myth — get() method waits till the page is loaded while navigate() does not.
Referring to the selenium official doc, get() method is a synonym for to() method. Both do the same thing.
**Myth _— _**get() does not store history while navigate() does.
All the URL loaded in browser will be stored in history and navigate method allows us to access it. Try executing the below code
driver.get(“http://madhank93.github.io/"); driver.get(“https://www.google.com/"); driver.navigate().back();
6. Find element VS Find elements
When no match has found(0) throws NoSuchElementException when 1 match found returns a WebElement instance when 2 matches found returns only the first matching web element
when no macth has found (0) returns an empty list when 1 match found returns a list with one WebElement when 2+ matches found returns a list with all matching WebElements
Selenium webdriver methods in java
Creates a new browser window and switches the focus for future commands of this driver to the new window.
Uses of WebDriver in org.openqa.selenium.bidi
Uses of WebDriver in org.openqa.selenium.bidi.browsingcontext
Uses of WebDriver in org.openqa.selenium.chrome
Uses of WebDriver in org.openqa.selenium.chromium
Uses of WebDriver in org.openqa.selenium.devtools
Uses of WebDriver in org.openqa.selenium.edge
Uses of WebDriver in org.openqa.selenium.firefox
Uses of WebDriver in org.openqa.selenium.grid.session.remote
Uses of WebDriver in org.openqa.selenium.ie
Uses of WebDriver in org.openqa.selenium.interactions
Uses of WebDriver in org.openqa.selenium.logging
Uses of WebDriver in org.openqa.selenium.remote
Modifier and Type | Class | Description |
---|---|---|
class | RemoteWebDriver |
Modifier and Type | Method | Description |
---|---|---|
WebDriver | Augmenter. augment (WebDriver driver) | Enhance the interfaces implemented by this instance of WebDriver iff that instance is a RemoteWebDriver . Enhance the interfaces implemented by this instance of WebDriver iff that instance is a RemoteWebDriver . Uses of WebDriver in org.openqa.selenium.safariA WebDriver implementation that controls Safari using a browser extension (consequently, only Safari 5.1+ is supported). Uses of WebDriver in org.openqa.selenium.supportUses of WebDriver in org.openqa.selenium.support.decoratorsThis class helps to create decorators for instances of WebDriver and derived objects, such as WebElement s and Alert , that can extend or modify their «regular» behavior. Uses of WebDriver in org.openqa.selenium.support.eventsThis decorator creates a wrapper around an arbitrary WebDriver instance that notifies registered listeners about events happening in this WebDriver and derived objects, such as WebElement s and Alert . |