Found 719 Articles for Testing Tools

What is the difference between mocha and Selenium?

Debomita Bhattacharjee
Updated on 01-Feb-2021 11:51:55

347 Views

The differences between Mocha and Selenium are listed below −VsFunctionalitiesMochaSeleniumPurposeIt is an easy, workable and popular JavaScript framework developed for Node.js.It is a free automation tool used for testing the web.LanguageBased on JavaScript.Can be used with multiple languages like Java, Python, C#, Ruby, JavaScript, and so on.UsageUsed for integration, unit and end to end testing.Used for web based automation testing.XUnit frameworkIt contains the XUnit reporter which yields an XML document.It cannot be used with XUnit Framework.BrowserSupports mostly Chrome and Firefox. It can be used for other browsers with certain challenges.Supports the majority of browsers like Chrome, Firefox, Safari, IE, and ... Read More

The best way to inspect HTTP response headers with Selenium

Debomita Bhattacharjee
Updated on 01-Feb-2021 11:51:00

3K+ Views

We can inspect HTTP response headers with Selenium webdriver. To verify the HTTP header, we should get the response from a source. Some of the HTTP response codes are listed below −5XX − Represents server concerns.4XX − Represents issues in resource detection.3XX − Represents response redirection.2XX − Represents correct ocde.The HttpURLConnection class is used to obtain the HTTP response code. To have a link to an URL, the method openConnection is used. Then, we have to use the setRequestMethod method and pass HEAD as parameter to it.The connect method is applied on the object of the HttpURLConnection class. Finally, the ... Read More

How do I automatically download files from a pop up dialog using selenium-python?

Debomita Bhattacharjee
Updated on 01-Feb-2021 11:47:42

2K+ Views

We can automatically download files from a pop up dialog using Selenium webdriver with Python. After clicking the download link, a dialog box appears for the user to select various options to Save the file.We have to programmatically configure the path where the download has to be performed such that every time the Firefox browser is launched, the Firefox profile is proper to perform the download at the desired location.Open the address bar of Firefox, and enter about:config and press Enter . All the browser preferences shall be available with Edit and Toggle buttons. We shall use the Firefox Options ... Read More

How to add custom ExpectedConditions for Selenium?

Debomita Bhattacharjee
Updated on 01-Feb-2021 11:46:26

936 Views

We can add custom ExpectedConditions for Selenium webdriver. We require this custom ExpectedConditions when the default expected conditions provided by webdriver are not enough to satisfy some scenarios.The method until is used which is a part of the WebDriverWait class. Here, the ExpectedConditions are used to wait for a specific criteria to be satisfied. This method pauses whenever one of the below incidents happen −The timeout duration specified has elapsed.The criteria defined yields neither false nor null.We can have a custom ExpectedCondition by creating an object of expected criteria and by taking the help of apply method.Let us take an ... Read More

How to get Firefox working with Selenium WebDriver on Mac OSX?

Debomita Bhattacharjee
Updated on 01-Feb-2021 11:46:38

4K+ Views

We can get Firefox working with Selenium webdriver on Mac OS. For Firefox versions which are greater than 47, the geckodriver.exe file is to be used. We shall be able to launch the browser only after creating an object of the FirefoxDriver class.SyntaxWebDriver driver=new FirefoxDriver();Visit the link −  https://www.selenium.dev/downloads/ and go to the Browser segment. Click on the Documentation link below Firefox.In the Supported platforms page, click on geckodriver releases link.Then click on the link corresponding to Mac OS.Once downloaded, extract the file and save the geckodriver.exe file to the /usr/local/bin location. As in Windows, we do not need to ... Read More

How to mute all sounds in chrome webdriver with selenium?

Debomita Bhattacharjee
Updated on 30-Jan-2021 13:11:00

1K+ Views

We can mute all sounds in Chrome with Selenium webdriver. To mute the audio we have to set parameters for the browser. For Chrome, we shall use the ChromeOptions class.We shall create an object of the ChromeOptions class. Then utilize that object to invoke the addArguments method. Then pass −mute−audio as a parameter to that method. Finally, send this information to the driver object.SyntaxChromeOptions op = new ChromeOptions(); op.addArguments("−−mute−audio"); WebDriver d = new ChromeDriver(op);For Firefox, we shall use the FirefoxOptions class and create an object for that class. Then utilize that object to invoke the addPreference method and pass media.volume_scale ... Read More

Make Selenium wait 10 seconds.

Debomita Bhattacharjee
Updated on 30-Jan-2021 13:09:26

11K+ Views

We can make Selenium wait for 10 seconds. This can be done by using the Thread.sleep method. Here, the wait time (10 seconds) is passed as a parameter to the method.We can also use the synchronization concept in Selenium for waiting. There are two kinds of wait − implicit and explicit. Both these are of dynamic nature, however the implicit wait is applied to every step of automation, the explicit wait is applicable only to a particular element.ExampleCode Implementation with sleep method.import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class WaitThrd{    public static void main(String[] args)    throws ... Read More

Maximize WebDriver (Selenium 2) in Python.

Debomita Bhattacharjee
Updated on 30-Jan-2021 13:07:39

205 Views

We can maximize browser window with Selenium webdriver in Python. It is a good practise to maximize the browser while running the tests to reduce the chance of failure.Once a browser is maximized, the majority of elements become visible to the screen and the probability of interaction with the driver increases. Also, with a maximized browser, users have a better view of the elements on the page.Some of ways of maximizing browser −With the maximize_window methodSyntaxdriver.maximize_window()With the fullscreen_window methodSyntaxdriver.fullscreen_window()ExampleCode Implementation with maximize_window()from selenium import webdriver #set chromedriver.exe path driver = webdriver.Chrome (executable_path="C:\chromedriver.exe") # maximize browser driver.maximize_window() driver.get("https://www.tutorialspoint.com/index.htm") driver.close()ExampleCode Implementation with ... Read More

Take screenshot of full page with Selenium Python with chromedriver.

Debomita Bhattacharjee
Updated on 30-Jan-2021 13:06:31

4K+ Views

We can take a screenshot of a full page with Selenium webdriver in Python with chromedriver. First of all, we shall obtain the original window size with the get_window_size method.Then with the help of JavaScript Executor we shall fetch the complete height and width of the page which is opened on the browser. Then set the window size to that dimension with the set_window_size method.Next, capture the screenshot of the entire content within the body tag in the html with the screenshot method. This method accepts the path of the screenshot that will be captured as a parameter.Examplefrom selenium import ... Read More

How could I start a Selenium browser(like Firefox) minimized?

Debomita Bhattacharjee
Updated on 30-Jan-2021 13:04:12

267 Views

We can start the Selenium browser(like Firefox) in minimized mode. This will be achieved by taking the help of the Dimension class. We shall create an object of this class.While creating the object , we shall pass the dimensions of the browser size as parameters to the Dimension class. Finally pass the object as parameter to the setSize method.SyntaxDimension s = new Dimension(100, 200); driver.manage().window().setSize(s);Exampleimport org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.Dimension; public class FirefoxBrwSize{    public static void main(String[] args) {       System.setProperty("webdriver.gecko.driver",          "C:\Users\ghs6kor\Desktop\Java\geckodriver.exe");       WebDriver driver = new ... Read More

Advertisements