Posts

Showing posts with the label Selenium

Handling Keyboard actions in Selenium

sendKeys() of WebElement interface can be used to press the specified keys of Keyboard. Keys is the predefined class of WebDriver API We can use below different ways: 1. Using Actions Class Actions action =new Actions(driver); action.sendKeys(Keys.ENTER).build( ).perform( ); 2. Using chrod() predefined method of Keys() class We can simultaneously press multiple keys using chrod() WebElement textPassword= driver.findElement(By.id("txtPassword")); textPassword.sendKeys(Keys.chord(Keys.CONTROL, "a"), Keys.DELETE);

Running Selenium WebDriver without using EXE files

In order to run Selenium WebDriver on Chrome, Firefox, IE etc browser we need to set exe binary file path like below before initiate drivers. System.setProperty("webdriver.chrome.driver", "/absolutepathtobinarychromedriver"); System.setProperty("webdriver.gecko.driver", "/absolutepathtobinarygeckodriver"); If you forgot to set path to the driver executable file using System.setProperty then illegal state exception will occur. To avoid this we can use WebDriverManager in Maven project, you need to add the following dependency in your pom.xml file. <dependency>     <groupId>io.github.bonigarcia</groupId>     <artifactId>webdrivermanager</artifactId>     <version>3.0.0</version>     <scope>test</scope> </dependency> and in Gradle project dependencies {     testCompile("io.github.bonigarcia:webdrivermanager:3.0.0") } WebDriverManager resolves the driver ...