Found 871 Articles for Automation Testing

Browsers and Platforms supported by Selenium Tools.

Debomita Bhattacharjee
Updated on 30-Nov-2020 10:40:37

327 Views

Selenium is a suite of tools which is used to a large extent by the testing community. It cannot test the desktop application and can only automate web based test cases.Some of the popular browsers supported are −FirefoxChromeIESafariOperaSome of the popular operating systems supported are −Linux/UnixMacWindowsAnother fact, why Selenium is so popular is that, it can work on different programming languages like −JavaPythonJavaScriptRubyC#PHPSome of the components of Selenium are −Selenium IDESelenium RCSelenium WebdriverSelenium Grid

Clear text from textarea with selenium.

Debomita Bhattacharjee
Updated on 30-Nov-2020 10:39:37

2K+ Views

We can clear text from a text area with Selenium. We shall use the clear method to remove the content from a text area or an edit box. First we shall identify the text area with the help of any locator.A text area is identified with textarea tagname in the html code. Let us input some text inside the below text area, then clear the text.Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class TextAreaClear{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver driver = new ChromeDriver();       driver.get("http://www.uitestpractice.com/Students/Form"); ... Read More

Typing Enter/Return key in Selenium.

Debomita Bhattacharjee
Updated on 31-Oct-2023 03:01:12

23K+ Views

We can type Enter/Return key in Selenium. We shall use the sendKeys method and pass Keys. ENTER as an argument to the method. Also, we can use pass Keys. RETURN as an argument to the sendKeys method for the same purpose.To use the Keys class, we have to incorporate import org.openqa.selenium.Keys to the code. Let us type Enter/Return after inputting text within the below edit box.Exampleimport org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.By; import org.openqa.selenium.Keys; public class TypeEnter{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver",       "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver driver = new ... Read More

Wait for complex page with JavaScript to load using Selenium.

Debomita Bhattacharjee
Updated on 30-Nov-2020 10:34:40

3K+ Views

We can wait for a complex page with JavaScript to load with Selenium. After the page is loaded, we can invoke the Javascript method document.readyState and wait till complete is returned.SyntaxJavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript("return document.readyState").toString().equals("complete");Next, we can verify if the page is ready for any action, by using the explicit wait concept in synchronization. We can wait for the expected condition presenceOfElementLocated for the element. We shall implement the entire verification within the try catch block.Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import org.openqa.selenium.JavascriptExecutor; public class PageLoadWt{    public static void main(String[] args) { ... Read More

How to install Selenium WebDriver on Mac OS?

Debomita Bhattacharjee
Updated on 30-Nov-2020 10:32:25

3K+ Views

We can install Selenium on Mac OS. We shall take the help of Homebrew package manager for installation in Mac OS. Let us follow the step by step process −Install Selenium by running the command −pip install seleniumInstall the Chrome driver with the homebrew by running the command −brew cask install chromedriverVerify the version of the Chrome driver, by running the command −chromedriver −−versionCreate a test script and try to execute after save.from selenium import webdriver # driver initialization driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") # launch URL driver.get("https://www.tutorialspoint.com/index.htm")If the below error is triggered −unknown error: cannot find chrome binaryIt means the version ... Read More

Capturing JavaScript error in Selenium.

Debomita Bhattacharjee
Updated on 30-Nov-2020 10:29:16

1K+ Views

We can capture Javascript error in Selenium. This type of error appears at the Console Tab on opening the Developer tools in the browser. This can occur due to some functional issue in the page or due to extra logs which may cause performance issues.We can handle the Javascript errors with the driver object and manage method.Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.List; import java.util.ArrayList; import org.openqa.selenium.logging.LogEntries; import org.openqa.selenium.logging.LogEntry; import org.openqa.selenium.logging.LogType; import java.util.logging.Level; import java.util.Set; public class JavascrptLogErs{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver",       "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver ... Read More

Switch tabs using Selenium WebDriver with Java.

Debomita Bhattacharjee
Updated on 30-Nov-2020 10:27:09

13K+ Views

We can switch tabs using Selenium. First we have to open a link in a new tab. The Keys.chord method along with sendKeys is to be used. The Keys.chord method allows you to pass more than one key at once. The group of keys or strings are passed as arguments to the method.We shall pass Keys.CONTROL and Keys.ENTER as arguments to the Keys.chord method. The whole string is then passed as an argument to the sendKeys method. Finally, the sendKeys method has to be applied on the link which is identified by driver.findElement method.SyntaxString clickl = Keys.chord(Keys.CONTROL, Keys.ENTER); driver.findElement(By.xpath("//*[text()='Terms of ... Read More

Capturing browser logs with Selenium WebDriver using Java.

Debomita Bhattacharjee
Updated on 30-Nov-2020 10:25:01

920 Views

We can capture browser logs with Selenium. We have to type cast the RemoteWebDriver to driver and then initialize it. Next, we have to use the setLogLevel method. The import org.openqa.selenium.remote.RemoteWebDriver statement needs to be added in code for the RemoteWebDriver.Syntax((RemoteWebDriver) driver).setLogLevel(Level.INFO);Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.remote.RemoteWebDriver import java.util.logging.Level; public class BrwLogs{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver",       "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver driver = new ChromeDriver();       // Enable logging with setLogLevel method       ((RemoteWebDriver) driver).setLogLevel(Level.INFO);       driver.get("https://www.tutorialspoint.com/index.htm");       ... Read More

How to handle authentication popup with Selenium WebDriver using Java?

Debomita Bhattacharjee
Updated on 30-Nov-2020 10:23:19

3K+ Views

We can handle authentication popup with Selenium. To do this, we have to pass the user credentials within the URL. We shall have to add the username and password to the URL.Syntaxhttps://username:password@URL https://admin:admin@the−nternet.herokuapp.com/basic_auth Here, the admin is the username and password. URL − www.the-internet.herokuapp.com/basic_authLet us work and accept the below authentication popup.Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class AuthnPopup{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver",       "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver driver = new ChromeDriver();       String u = "admin";       // adding username, password with ... Read More

Why do we use WebDriver instead of Selenium IDE?

Debomita Bhattacharjee
Updated on 30-Nov-2020 10:21:11

351 Views

We can use webdriver instead of Selenium IDE. The Selenium IDE is a record and playback tool but not dependable. The web elements which are dynamic cannot be handled well with Selenium IDE.Selenium IDE can be used for an easy solution to automation, but for a full regression suite, Selenium webdriver should be used. Some of the differences between Selenium IDE and Selenium webdriver are −Sl. No.Selenium IDESelenium Webdriver1.It supports only Firefox.It supports all the major browsers.2.Simply a record and playback tool.Not a record and playback tool.3.Architecture based on Javascript.Architecture not based on Javascript. Communicates with browser applications.4.Does not support ... Read More

Advertisements