All Selenium Java Commands
All Selenium Java Commands
All Selenium Java Commands
examples
In Java
actions.doubleClick(element).perform(); // Double-click
By default these are hard assertions, means if these fail then tests will be
exited or stopped
softassert.assertEquals(ActualTitle, ExpectedTitle);
softassert.assertAll();
By default these assertions, do not stop if these assertions fail & are reported
in your test reports
These are conditional waits & can be applied to satisfy a particular condition, then
continue test execution if condition met or failed if not met in mentioned amount of time
Once the command is run, Implicit Wait remains for the entire duration for which
the browser is open. It’s default setting is 0, and the specific wait time needs to be
set by the following protocol.
actions.keyDown(Keys.CONTROL).sendKeys("a").keyUp(Keys.CONTROL).perfor
m(); // Ctrl+A
actions.keyDown(Keys.SHIFT).sendKeys("hello").keyUp(Keys.SHIFT).perform(); //
Type "HELLO"
actions.sendKeys(Keys.ENTER).perform(); // Press Enter
actions.contextClick(element).perform(); // Right-click
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("window.scrollTo(0, 1000)");
js.executeScript("document.getElementById('myElement').click();");
Create custom test reports: Utilize third-party libraries like ExtentReports or Allure
or TestNG reports
options.addArguments("--headless");
options.addArguments("--start-maximized");
uploadElement.sendKeys("C:\\path\\to\\file.txt");