How to take a screenshot in Selenium WebDriver

How to take a screenshot in Selenium WebDriver
One of the most useful capabilities of the WebDriver is to take a screen shot when it fails during the execution time and save it to a safe location so that it can be seen later to get to know where the test is failed. By default screenshot capability is enabled in all major browsers. By the way, TakesScreenshot is an interface and is implemented by Firefox, Opera, Chrome, IE Driver
and so on. In three variant formats, WebDriver provides taking screen shot such as BASE64, FILE and BYTES (raw data). If FILE format is chosen, a (dot) png file is used to write the data into it, once the JVM is killed automatically after the session file is deleted unless it is saved in a local or a remote machine.

//take and save screen shot
File sourceFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(sourceFile, new File("C:\\Users\\Public\\Pictures\\testStartBrowser.png"));
//print out here file is saved

Explicitly Wait in Selenium WebDriver

Explicitly Wait in Selenium WebDriver Explicitly wait time is configured to look for only a particular WebElement in the DOM before the test proceed further. On the other hand, Thread.sleep() sets the condition to wait for the specified period of time which makes the test much slower. The main goal of using explicitly wait is to execute the automation testing faster. The following code was taken from the test:

//wait for 2 secs
Here note that static Thread is good for visualizing the actions while performing the test for the front-end. I highly recommend not to use static wait because it always makes the test slower. A Static wait is fixed meaning that 2 seconds should be waited before it goes to the next element. 
//stop resharing
driver.findElement(By.cssSelector("div.Dp div")).click();
One of the ways, it can be accomplished with ExpectedConditions. Below it is shown taken from the real test:
//wait for the element 35 secs max
WebDriverWait wait = new WebDri…

Implicitly Wait in Selenium WebDriver

Implicitly Wait in Selenium WebDriver
Implicitly wait is associated to a global timeout period and is common to all WebElements. This is used to configure the wait time of WebDriver as a whole for the AUT. Obviously, depending on the network speed test execution time can be decreased or increased. If an application is hosted on a local machine always takes less time comparing the same application hosted on a remote server would take more time to load a page. In addition to that, wait time would be configured considering the cases accordingly so that tests do not spend more time to wait for the page to be loaded or spend less time and timeout. WebDriver provides a method called manage() to handle such issues in order to set the implicitly wait time. Using implicitly wait time, the maximum wait time can be set for all WebElements on the webpage. Furthermore, Before WebDriver reaches the maximum time out; it polls the DOM for the WebElements for a certain period of time on the page. Ho…

Browser's Profile in Selenium WebDriver

Browser's Profile in Selenium WebDriver
Before we start off the Selenium WebDriver, we need to clarify some basic ideas.In this article, we will discuss about Firefox browser's profile , for example, mainly a custom Firefox Profile and an Anonymous Profile.This a basic concept that most of the Internet users know about it.However, I thought that it will be helpful to start from the ground.
 A Firefox browser uses a folder that is known as Firefox profile to store users bookmarks settings, passwords as well as all other data. Any number of profiles can be created by a Firefox user with different custom settings and can use it accordingly.If you intend to see the profile folder from the browser you just open the browser and type in the address bar or navigate to Help from the browser menu; then choose Troubleshooting Information.Here check Application Basics section for Profile Directory.

To create, edit or delete any Firefox profile in Firefox please follow the instruction here…