Found 719 Articles for Testing Tools

Selenium WebDriver: I want to overwrite value in field instead of appending to it with sendKeys using Java

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:29:51

1K+ Views

We can overwrite the value in the field instead of appending to it with sendKeys in Selenium webdriver. This can be done by using the Keys.chord method.It returns a string and can be applied to any web element with the help of the sendKeys method.To overwrite a value, we shall first select it with CTRL+A keys and then pass the new value. Thus, Keys.CONTROL, A and the new value are passed as parameters to the Keys.chord method.SyntaxString n = Keys.chord(Keys.CONTROL, "A"); WebElement l = driver.findElement(By.name("q")); l.sendKeys(n, "Tutorialspoint");Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.Keys; public class ... Read More

How to launch Edge browser with Selenium Webdriver?

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:29:11

7K+ Views

We can launch Edge browser with Selenium webdriver by using the Microsoft webdriver. We should also ensure that we are having the machine with the Windows 10 operating system.Navigate to the below link to download the Microsoft Edge driver executable file − https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/Once the page is launched, scroll down to the Downloads section, then choose and click the link which is compatible with our local Edge browser version.A zip file gets created, once the download is completed successfully. We have to then unzip the file and save it in a desired location. Then, set the path of the msedgedriver.exe file. ... Read More

How can I handle multiple keyboard keys using Selenium Webdriver?

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:21:31

2K+ Views

We can handle multiple keyboard keys in Selenium webdriver by using the method Keys.chord. The multiple keyboard keys to be handled are passed as parameters to this method.The return type of the Keys.chord method is a string and can be applied to an element with the help of the sendKeys method. For example, in order to perform a select operation on text entered inside an edit box we require the keys ctrl+a to be pressed simultaneously.SyntaxString k = Keys.chord(Keys.CONTROL, "A"); driver.findElement(By.name("q")).sendKeys(k);Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.Keys; public class MultipleKeys{    public static void main(String[] ... Read More

How to open new tab in same browser and switch between them using Selenium?

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:17:45

6K+ Views

We can open new tabs in the same browser and switch between them using Selenium webdriver. Firstly, to open a new tab in the same browser we have to take the help of the methods – Keys.chord and sendKeys.The parameters Keys.CONTROL and Keys.ENTER are passed to the Keys.chord method. This method yields a string value and in turn passed as a parameter to the sendKeys method.SyntaxString n = Keys.chord(Keys.CONTROL, Keys.ENTER); driver.findElement(By.id("open-tab")).sendKeys(n);Once the second tab is opened, the getWindowHandles method is used to hold all the window handle ids in a Set. To shift the focus of the webdriver object to ... Read More

How to scroll up/down a page using Actions class in Selenium?

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:14:47

10K+ Views

We can perform scroll up/down a page using Actions class in Selenium webdriver. First of all, we have to create an object of this Actions class and then apply the sendKeys method on it.Now, to scroll down a page, we have to pass the parameter Keys.PAGE_DOWN to this method. To again scroll up a page, we have to pass the parameter Keys.PAGE_UP to the sendKeys method. Finally, we have to use the build and perform methods to actually perform this action.SyntaxActions a = new Actions(driver); //scroll down a page a.sendKeys(Keys.PAGE_DOWN).build().perform(); //scroll up a page a.sendKeys(Keys.PAGE_UP).build().perform();Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; ... Read More

How to open a browser window in full screen using Selenium WebDriver with C#?

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:13:21

1K+ Views

We can open a browser window in full screen using Selenium webdriver in C# by using the method Maximize. This method has to be applied on the webdriver object.Syntaxdriver.Manage().Window.Maximize();Exampleusing NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using System; namespace NUnitTestProject1{    public class Tests{       String url = "https://www.google.com/";       IWebDriver driver;       [SetUp]       public void Setup(){          //object of FirefoxDriver          driver = new FirefoxDriver();       }       [Test]       public void Test1(){          //URL launch          driver.Navigate().GoToUrl(url);          //browser maximize          driver.Manage().Window.Maximize();          Console.WriteLine("Browser Maximized");       }       [TearDown]       public void closeBrowser(){          driver.Quit();       }    } }Output

Select item from sub-menu of a menu using mouse over action in Selenium

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:09:29

6K+ Views

We can select an item from the sub-menu of a menu using mouse over action in Selenium webdriver with the help of the Actions class. We shall create an object of the Actions class and then apply moveToElement to it.This method shall move the mouse to the middle of the menu which displays submenu on mouse over. Then apply the perform method to actually perform this action. After hovering on the menu, we shall select a sub-menu with the help of the click method.SyntaxWebElement n=driver.findElement(By.id("nav-link-accountList")); Actions a = new Actions(driver); a.moveToElement(n).perform();Let us hover on the below highlighted menu on the ... Read More

Alternative of click() in Selenium

Debomita Bhattacharjee
Updated on 06-Apr-2021 11:58:14

5K+ Views

There are several alternatives to the usage of click method in Selenium webdriver. We can use the JavaScript Executor to perform a click action. Selenium can execute JavaScript commands with the help of the executeScript method.The parameters – arguments[0].click() and locator of the element on which the click is to be performed are passed to this method.SyntaxWebElement n=driver.findElement(By.linkText("Refund")); JavascriptExecutor j = (JavascriptExecutor) driver; j.executeScript("arguments[0].click();", n);Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.JavascriptExecutor; public class JsClickLink{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); ... Read More

Google Search Automation with Python Selenium

Debomita Bhattacharjee
Updated on 06-Apr-2021 11:57:39

7K+ Views

We can perform Google search automation with Selenium webdriver in Python. First of all, we shall locate the Google search box with the help of any of the locators like id, css, xpath, class, or name.Then simulate the action of pressing the ENTER key with the help of Keys.ENTER/Keys.RETURN. To perform this operation, we have to use the method send_keys and then pass the parameter – Keys.RETURN /Keys.ENTER. Also, we have to add the statement - from selenium.webdriver.common.keys import Keys to use the Keys class.Examplefrom selenium import webdriver from selenium.webdriver.common.keys import Keys import time #set chromodriver.exe path driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") ... Read More

What is following-sibling in Selenium?

Debomita Bhattacharjee
Updated on 06-Apr-2021 11:57:08

22K+ Views

We can use the concept of following-sibling in xpath for identifying elements in Selenium. It identifies the siblings of the context node. The siblings should be located at the equal level of the existing node and should have the same parent.Let us see an example of an element with ul tag having more than one child with li tag. Then let us try to locate the fifth li element (Effective Resume Writing) from the first li element with class attribute sreading.Syntax//li[@class='sreading']/following-sibling::li[4]Here, we are locating the fifth child of ul tag, but we have provided li[4] since we are locating the ... Read More

Advertisements