![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 871 Articles for Automation Testing
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
294 Views
We can check if DOM has a class using Selenium webdriver. We can use the findElements method to obtain the list of elements having a particular class. Then pass By.className or By.xpath or By.cssSelector as a parameter to the method.The class name we want to search is passed as a parameter to that method. Let us investigate the below html code for an ul element having class value as toc chapters. Then obtain its sub-elements.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; public class ClassAttrb{ public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
96 Views
We can take screenshots of tests in Selenium webdriver. Capturing a screenshot is one of the most essential steps in failure analysis of failed tests. It is a three way step process to take screenshots.Firstly, we shall convert the webdriver object to the interface called the TakeScreenshot. Then we have to utilize the getScreenshotAs method to capture the image. The file format of the image to be captured is passed as parameter to that method.Finally, the file where the image is captured is to be copied to a location with the FileUtils.copyFile method.SyntaxFile s = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(s, new File("Image.png"));Exampleimport org.openqa.selenium.By; ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
2K+ Views
There are differences between executeAsyncScript and executeScript methods. For an executeScript method, JavaScript Executor runs the JavaScript with the reference to the present selected window or frame. The script within the method shall run as the body of the unnamed function.Inside the script, the documents are used to point to the present document. Also, the local variables will not be present as the script has completed execution. However, the global variables shall be present.If the script consists of a return statement, then the below rules are followed −A webelement is returned for an HTML element.A double is returned for a ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
459 Views
We can make Selenium wait for the page to load. We can use the synchronization concept in Selenium to wait for page loading. The implicit wait is a type of synchronization applied to elements to wait for a specified amount of time.Syntaxdriver.manage().timeouts().implicitlyWait();We can also call the JavaScript method document.readyState and wait till it yields the value complete. Selenium executes JavaScript command with the help of the executeScript method.SyntaxJavascriptExecutor j = (JavascriptExecutor)driver; j.executeScript("return document.readyState").toString().equals("complete");Post this step, we should check if the URL is similar to the one we are looking for.ExampleCode Implementation with implicit wait.import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
6K+ Views
We can verify if an element does not exist in Selenium webdriver. To achieve this, we shall use the method getPageSource which gets the entire page source. So we can obtain a complete page source and check if the text of the element exists.We also use the findElements method and utilize any locators like xpath, CSS, and so on to identify the matching elements. The findElements gives an elements list.We shall count the number of elements returned by the list with the help of the size method. If the value of size is greater than 0, then the element exists ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
2K+ Views
We can integrate Sikuli scripts into Selenium webdriver. Sikuli is an automation tool which is open-source. It has the feature to capture the images on the elements as well as perform operations on them.Some of the advantages of Sikuli are −Desktop or Windows applications can be automated.Can be used for flash testing.Can be used on platforms like mobile, Mac, and Linux.It is based on image recognition technique.Can be easily integrated with Selenium.To integrate Sikuli with Selenium, follow the below steps − Navigate to the link − https://launchpad.net/sikuli/+download.Click on the jar to download it (which can be used for Java environments) ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
789 Views
We can select the dropdown option in Selenium webdriver. The dropdowns can be worked upon with the help of the Select class. The select tag is used to represent a dropdown and option tag is used to represent items in the dropdown in html.Let us investigate the html structure of a dropdown −We have to add the statement − import org.openqa.selenium.support.ui.Select to use the Select class methods. The Select class methods are listed below −selectByIndex(n) − An option is chosen based on the index of the option on the dropdown. The index n is passed as a parameter to the ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
6K+ Views
We can resolve StaleElementReferenceException in Selenium webdriver. The term stale means something which is not fresh and decayed. Thus a stale element points to an element which is not present any more.There may be a case, when an element was in DOM initially but after modifications in Document Object Model (DOM), the element becomes stale and the StaleElementReferenceException is thrown if we make an attempt to access this element.This exception is caused whenever an element is not present in the DOM, or deleted. We can handle this exception by the following ways −Refreshing the page and verifying again.Implement retry method.ExampleCode ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
3K+ Views
We can click on the hidden element in Selenium webdriver. In DOM, the hidden elements are the ones which are not displayed on the page. CSS property style should have the value display:none set for the hidden elements. Also, if the hidden element resides within a form tag, it can be made hidden by setting the attribute type to hidden.ElementNotVisibleException is thrown by Selenium while handling hidden elements. So JavaScript Executors can be utilized to access and handle these elements. The executeScript method is used in Selenium to execute the JavaScript commands. The commands to be executed are passed as ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
2K+ Views
We can convert commands recorded in Selenium IDE to Java. To convert commands first navigate to File menu, then select the option Export Test case As.After clicking it, all the possible options for conversion get displayed. Choose the option Java/ Junit 4/ WebDriver.Finally, we have to save the file with the .java extension. Then we can open this file using a text Editor or IDE.We can also convert commands recorded in Selenium IDE to Java by navigating to the Options menu. As the Selenium IDE Options pop−up comes up, select the checkbox Enable experimental features. Then click on OK.Next, select ... Read More