Found 719 Articles for Testing Tools

Find Element and FindElements by XPath in Selenium

Debomita Bhattacharjee
Updated on 06-Apr-2021 10:34:59

5K+ Views

The findElement(By.xpath) method is used to identify an element which matches with the xpath locator passed as a parameter to this method. The findElements(By.xpath) method is used to identify a collection of elements which match with xpath locator passed as a parameter to that method.The method findElement(By.xpath) returns a web element whereas the method findElements(By.xpath) returns a list of web elements. An exception is thrown by the method findElement(By.xpath) if there is no matching element. An empty list of elements is returned if there is no matching element obtained from the findElements(By.xpath) method.Let us try to identify the number of ... Read More

How to run Selenium tests on Internet Explorer browser?

Debomita Bhattacharjee
Updated on 06-Apr-2021 10:32:12

242 Views

We can run Selenium tests on the Internet Explorer browser with the help of the Selenium IE driver. It is an independent server that works on the protocols of the webdriver and serves as a communication between the Internet Explorer browser and the Selenium code.First, we have to download the IEDriverServer.exe file from the following link − https://www.selenium.dev/downloads/.Then click on the download link (32 or 64 bit) based on our local operating system.Once the download is completed, a zip file gets saved. It needs to be extracted and stored in a location. After extracting it, the executable file - IEDriverServer.exe ... Read More

Selenium Webdriver Locating Strategies By Class Name

Debomita Bhattacharjee
Updated on 06-Apr-2021 10:29:12

629 Views

By class name can be used as a locating strategies in Selenium webdriver. We can identify an element utilizing class attribute with locators like class name, css and xpath. To locate webelement with css, the syntax is tagname[class='value'] and the method to be used is By.cssSelector.To locate webelement with xpath, the syntax is //tagname[@class='value']. TThen, we have to use the method By.xpath to locate it. To locate an element with a locator class name, we have to use the By.className method.Let us look at the html code of web element having class attribute −SyntaxWebElement elm = driver. findElement(By.className("input__input")); WebElement p ... Read More

How to setup Chrome driver with Selenium on MacOS?

Debomita Bhattacharjee
Updated on 06-Apr-2021 10:28:13

5K+ Views

We can set up Chrome driver with Selenium on MacOS by the following steps. First we have to download the chromedriver.exe file from the below link − https://sites.google.com/a/chromium.org/chromedriver/downloadsBased on the local Chrome browser version, click on the link for download. In the next page, choose the option chromedriver_mac64.zip link for download for MacOS.Once the download is completed, a zip file gets created. We have to unzip it and we shall have a file called chromedriver. Next, launch the Finder window and click on the Go menu from the top. Then, click on the Go to Folder.Enter /usr/local/bin and select Go ... Read More

The xpath of the element keeps changing, how do I find dynamic xpath for this element in Selenium

Debomita Bhattacharjee
Updated on 06-Apr-2021 10:26:15

2K+ Views

We can find the xpath of the element that keeps changing with the help of the xpath functions. They help to identify an element having dynamic attribute value or text. Some of these functions are listed below −text() – Identifies an element with the help of the visible text on the page. The xpath expression for the element Home is //*[text()='Home'].starts-with – Identifies an element whose attribute value begins with a specific text. This function is normally used for attribute values which are dynamic in nature.The xpath expression of Home is //a[starts-with(@title, 'Questions &')].contains - Identifies an element whose attribute ... Read More

When do we use findElement() and findElements() in Selenium?

Debomita Bhattacharjee
Updated on 06-Apr-2021 10:25:44

4K+ Views

The methods findElements and findElement are used to identify elements on a webpage. While findElement can pinpoint only one element, the findElements method yields a list of matching web elements.The return type of findElements is a list whereas the return type of findElement is a WebElement. If there is no matching element on the page, an exception is thrown by the findElement method. In this scenario, an empty list id returned by the findElements method.A good example of findElements method usage is counting the total number of links or accessing each of links by iterating through the links.SyntaxWebElement m = ... Read More

How to run Selenium tests on Chrome Browser using?

Debomita Bhattacharjee
Updated on 06-Apr-2021 10:21:48

607 Views

We can run Selenium tests on Chrome browser with the help of the chromedriver.exe executable file. First, we have to download the chromedriver.exe file from the following link − https://sites.google.com/a/chromium.org/chromedriver/downloadsWe have to click on the link which matches with the Chrome browser in our system. Next, choose the link based operating system (Windows, Linux or Mac) we are presently using.Once the download has completed, a zip file gets created. We have to extract the zip file and store the chromedriver.exe file in a desired location. Then, we have to configure the path of the chromedriver.exe file using the System.setProperty method ... Read More

How to scroll a Web Page using coordinates of a WebElement in Selenium WebDriver?

Debomita Bhattacharjee
Updated on 06-Apr-2021 08:58:44

2K+ Views

We can scroll a webpage using coordinates of a webelement in Selenium webdriver using the JavaScript Executor. Selenium executes JavaScript commands with the help of the executeScript method.To get the unique coordinates of an element we shall create an object of the class Point which shall store the location of the webelement obtained from the getLocation method.Then the individual x and y coordinate values can be computed from the getX and the getY methods respectively. Finally, to actually perform scroll upto the coordinates of an element, the command window.scrollBy(x coordinate, y coordinate) is passed as a parameter to the executeScript ... Read More

How to Verify Tooltip using Selenium WebDriver?

Debomita Bhattacharjee
Updated on 06-Apr-2021 08:57:39

2K+ Views

We can verify the tooltip of an element using Selenium webdriver using the getAttribute method. A tooltip text is the one which gets displayed while we hover on that element.It disappears once we move the mouse away from the element. A tooltip text generally displays the title attribute value of an element. First, we identify the element then apply the getAttribute method on it. The parameter to be passed to this method is title.Let us investigate the html code of an element - Tools having a tooltip text.Here, the tooltip text displayed from Tools menu is Tools - Online Development ... Read More

What are the different ways to select an option from a dropdown using Selenium Webdriver?

Debomita Bhattacharjee
Updated on 06-Apr-2021 08:56:59

855 Views

We have different ways to select an option from a dropdown using Selenium webdriver. This is done with the help of the Select class. A dropdown in the html code is represented by select tag.The options in a dropdown are represented by the option tag. Also, we have to add the statement org.openqa.selenium.support.ui.Select to the code to work with dropdown.The different methods to select an option from a dropdown are listed below −selectByIndex – index of the option to be selected by the dropdown is passed as a parameter. The index starts from 0.WebElement e = driver.findElement(By.className("opt")); Select s = ... Read More

Advertisements