Found 719 Articles for Testing Tools

How to Disable images in Selenium Google ChromeDriver?

Debomita Bhattacharjee
Updated on 28-Dec-2020 11:13:43

621 Views

We can disable images in Selenium Google chromedriver. The images are disabled so that page load is quicker and execution time is also less. In chromedriver, we have to configure the below browser parameter −profile.managed_default_content_settings.images, and set its value to 2.Syntaxp.put("profile.managed_default_content_settings.images", 2);Let’s try to disable images from the below page −ExampleCode Implementation.import org.openqa.selenium.By; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import java.util.HashMap; import java.util.Map; public class ImageDisable {    public static void main(String[] args) throws IOException {       System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       Map p = new HashMap();       // browser setting to disable image       p.put("profile.managed_default_content_settings.images", ... Read More

Running Selenium Webdriver with a proxy in Python.

Debomita Bhattacharjee
Updated on 28-Dec-2020 11:07:38

4K+ Views

We can run a proxy with Selenium webdriver in Python. A proxy is an essential component to do localization testing. We can take an e-commerce application and check if the language and currency visible is as per the user location.With the help of proxy within tests, we can verify if the website user interface matches with the location. We have to SET a proxy with below steps −Import webdriver from Selenium package.Define proxy server address.Create an object of ChromeOptions classCommunication of proxy with ChromeOptions.Summing options to Chrome() object.ExampleCode Implementation.from selenium import webdriver #proxy server definition py = "128.21.0.0:8080" #configure ChromeOptions ... Read More

Clicking on elements within an SVG using XPath (Selenium WebDriver).

Debomita Bhattacharjee
Updated on 28-Dec-2020 11:06:01

11K+ Views

We can click on elements with an SVG using XPath in Selenium. The SVG element has the tag name svg. It has attributes like width, height, viewBox, and so on.To click the element with svg, we should identify the element then utilize the Actions class. We shall first move to that element with the moveToElement method and then apply the click method on it.Finally, to actually perform the action, we have to use the build and execute methods. To identify the svg element with xpath, there is the local-name() function available.Let us look at the html code of a svg ... Read More

How to hide Firefox window (Selenium WebDriver)?

Debomita Bhattacharjee
Updated on 28-Dec-2020 11:03:19

1K+ Views

We can hide the Firefox window in Selenium webdriver. This can be done by making the browser headless. We shall achieve this with the FirefoxOptions class. We shall then create an object option of that class.We have to make the browser setting options.headless to True value. This driver object shall then receive this information. We need to have the import statement: from selenium.webdriver.firefox.options import Options as FirefoxOptions for adding the FirefoxOptions class.Syntaxoptions = webdriver.FirefoxOptions() options.headless = TrueExampleCode Implementation.from selenium import webdriver from selenium.webdriver.firefox.options import Options as FirefoxOptions #object of FirefoxOptions options = webdriver.FirefoxOptions() #setting headless parameter options.headless = True driver ... Read More

How to upload a file in Selenium with no text box?

Debomita Bhattacharjee
Updated on 28-Dec-2020 11:01:34

3K+ Views

We can upload a file in Selenium with no text box. This is achieved with the help of the sendKeys method. It is applied on the web element which performs the task of selecting the path of the file to be uploaded.As we make an attempt to upload, we shall click on the Browse button. If we investigate the HTML code for this, we shall be able to locate the attribute type having the value file. Moreover, the file path to be uploaded should be accurate.ExampleCode Implementation.import 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; public class FileUpload{   ... Read More

How to simulate pressing enter in html text input with Selenium?

Debomita Bhattacharjee
Updated on 26-Oct-2020 07:33:51

627 Views

We can simulate pressing enter in the html text input box with Selenium webdriver. We shall take the help of sendKeys method and pass Keys.ENTER as an argument to the method. Besides, we can pass Keys.RETURN as an argument to the method to perform the same task.Also, we have to import org.openqa.selenium.Keys package to the code for using the Keys class. Let us press ENTER/RETURN after entering some text inside the below input box.ExampleCode Implementation with Keys.ENTER.import 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 PressEnter{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver", ... Read More

How do I change focus to a new popup tab in Selenium?

Debomita Bhattacharjee
Updated on 26-Oct-2020 07:32:15

3K+ Views

We can change focus to a new popup tab with Selenium webdriver. The getWindowHandles and getWindowHandle methods are available to handle new popup tabs. The getWindowHandles method stores all the currently opened window handles in Set data structure.The getWindowHandle method stores the window handle of the opened browser in focus. The iterator method is used to iterate over all the window handle ids. We have to add import java.util.Set to accommodate Set and import java.util.List and import java.util.Iterator statements to accommodate the iterator in our code.Selenium driver object can access the elements of the parent window. In order to switch ... Read More

How to wait until an element no longer exists in Selenium?

Debomita Bhattacharjee
Updated on 26-Oct-2020 07:30:40

6K+ Views

We can wait until an element no longer exists in Selenium webdriver. This can be achieved with synchronization in Selenium. We shall add an explicit wait criteria where we shall stop or wait till the element no longer exists.Timeout exception is thrown once the explicit wait time has elapsed and the expected behavior of the element is still not available on the page. To check if an element no longer exists on the page, we can take the help of the expected condition invisibilityOfElementLocated.To implement explicit wait conditions, we have to take help of the WebDriverWait and ExpectedCondition class.ExampleCode Implementation.import ... Read More

Selenium Web Test Automation Framework Best Practices.

Debomita Bhattacharjee
Updated on 26-Oct-2020 07:28:38

332 Views

The best practices for Selenium web test automation framework are listed below −Use of dynamic waits like implicit wait and explicit wait instead of using Thread.sleep in the framework to handle sync issues in the application.Usage of Page Object Model framework design to segregate the test scripts from the locators. In case of changes in the webelement properties, test scripts need not be modified only the locators undergo change.Usage of Behavior Driven Development framework. This allows the participation of all members in the agile team to participate in product development.Encourage testing to start from very early phases and in regular ... Read More

Get HTML Source of WebElement in Selenium WebDriver using Python.

Debomita Bhattacharjee
Updated on 26-Oct-2020 07:27:13

12K+ Views

We can get html source of a webelement with Selenium webdriver.We can get the innerHTML attribute to get the source of the web element.The innerHTML is an attribute of a webelement which is equal to the text that is present between the starting and ending tag. The get_attribute method is used for this and innerHTML is passed as an argument to the method.Syntaxs = element.get_attribute('innerHTML')We can obtain the html source of the webelement with the help of Javascript Executor. We shall utilize the execute_script method and pass arguments index.innerHTML and webelement whose html source is to be retrieved to the ... Read More

Advertisements