Found 871 Articles for Automation Testing

Behind the scenes working of Selenium.

Debomita Bhattacharjee
Updated on 28-Dec-2020 11:31:02

120 Views

The behind scenes workings of Selenium is illustrated below −Source − https://www.tutorialspoint.com/what-is-web-driver-in-seleniumSelenium webdriver architecture comprises of −Selenium Binding Languages – It can used on multiple languages (Java, Ruby, Javascript, C#, Python, and so on). So it possesses the language bindings for multiple languages.JSON Wire Protocol – It is known as the Javascript Object Notation. It sends the data from the server to the client page. It is built on the concepts of Rest API which conveys information within HTTP servers.Browser Driver – A browser has a browser driver. It communicates with its browser. When a driver gets a command, it ... Read More

How do you test pages that require authentication with Selenium?

Debomita Bhattacharjee
Updated on 28-Dec-2020 11:26:55

320 Views

We can test pages that need authentication with Selenium. For this, we have to send the credentials of the user to the URL. Actually, we are passing both the username and password appended to the URL.Syntaxhttps://username:password@URL https://admin:admin@the-internet.herokuapp.com/basic_authHere, the admin is the username and password.URL – www.the-internet.herokuapp.com/basic_authLet us see how to accept the authentication pop-up.ExampleCode Implementation.import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class TestAuthnPopup{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver driver = new ChromeDriver();       String t = "admin";       // adding username, password with ... Read More

How to use clickandwait in Selenium Webdriver using Java?

Debomita Bhattacharjee
Updated on 28-Dec-2020 11:24:42

2K+ Views

We can click and wait in Selenium. This can be achieved by the synchronization concept. We shall use the explicit wait condition and wait for an element to be clickable prior to the next step.The explicit wait waits for a specified amount of time before throwing an exception. To verify if an element is clickable, we can use the expected condition elementToBeClickable.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; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; public class ElementClickableWait{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver driver = new ChromeDriver();     ... Read More

How to connect to Chromium Headless using Selenium?

Debomita Bhattacharjee
Updated on 28-Dec-2020 11:21:59

372 Views

We can connect to Chromium headless with Selenium. The headless execution helps in reducing resource utilization and is a modern technique used in the industry.Chrome can be used in headless mode after the 59 version. The ChromeOptions class is used to change the default browser behavior. The headless value is passed to the addArguments method as a parameter for headless execution.SyntaxChromeOptions op = new ChromeOptions(); op.addArguments("headless"); WebDriver d = new ChromeDriver(op);ExampleCode Implementation.import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import java.util.concurrent.TimeUnit; public class HeadlessChromium{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       //ChromeOptions object     ... Read More

How to get HTTP Response Code using Selenium WebDriver?

Debomita Bhattacharjee
Updated on 28-Dec-2020 11:16:29

5K+ Views

We can get an HTTP response code in Selenium webdriver. While running test cases, we can check the response code from a resource. Common HTTP response codes include −5XX – Issue in server.4XX – Resource cannot be determined.3XX - Redirection.2XX – Fine.An object of the class HttpURLConnection is created to get the HTTP response code. To establish a link to an URL, the openConnection method shall be used. Next, we shall utilize the setRequestMethod and pass HEAD as a parameter.For connection, the connect method is to be applied to the instance of the HttpURLConnection class. At last, the getResponseCode method ... Read More

How to Disable images in Selenium Google ChromeDriver?

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

610 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

10K+ 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

2K+ 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

Advertisements