Found 871 Articles for Automation Testing

Is navigate method available in Selenium Webdriver with Python?

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

530 Views

The navigate method is not available in Selenium webdriver with Python.In order to navigate to a page, we can use the get method and pass the URL of the page that we want to launch as a parameter.In this method the webdriver waits till the webpage is completely loaded prior transferring the control to the next step in the test case. If the page that we are trying to load, has multiple AJAX calls after loading, then the webdriver becomes unaware when the page will ultimately load.We can use the different wait methods in synchronization to handle such a scenario. ... Read More

Which exception is raised when an element is not found in an HTML DOM using XPath in Selenium?

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

1K+ Views

If an element is not found in an HTML DOM using xpath, then the NoSuchElementException is raised. This exception is thrown when the webdriver makes an attempt to locate a web element which is absent from DOM. This is normally encountered if we create an incorrect xpath for an element.The below image shows an example of NoSuchElementException..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 ElemntsText{    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 get the text from a website using selenium?

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

3K+ Views

We can get the text from a website using Selenium webdriver USING the getText method. It helps to obtain the text for a particular element which is visible or the inner text (which is not concealed from the page).First of all, we have to identify the element on the page for which we want to get the text with the help of any locators like id, class, name, xpath, css, tag name, link text or partial link text.Let us try to retrieve the text - ENJOY PREMIUM CONTENT AT AFFORDABLE PRICE from the below page −SyntaxWebElement n =driver.findElement(By.tagName("h2")); String s ... Read More

How to find an element using the “Link Text/Partial Link Text” in Selenium?

Debomita Bhattacharjee
Updated on 06-Apr-2021 10:39:16

5K+ Views

We can find an element using the link text or the partial link text in Selenium webdriver. Both these locators can only be applied to elements with the anchor tag.The link text locator matches the text inside the anchor tag. The partial link text locator matches the text inside the anchor tag partially. NoSuchElementException shall be thrown for both these locators if there is no matching element.SyntaxWebElement n =driver.findElement(By.partialLinkText("Coding")); WebElement l =driver.findElement(By.linkText("Coding Ground"));Let us find the below highlighted element CODING GROUND on the page −ExampleCode Implementation with linkTextimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import java.util.concurrent.TimeUnit; public class LnkTxt{ ... Read More

How to capture tooltip in Selenium using getAttribute?

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

464 Views

We can capture the tooltip in Selenium using the getAttribute method.This technique can only be used for an element which has the attribute in its html code.A tooltip text becomes visible from an element as we hover the mouse on it. To obtain the tooltip we have to pass the title as a parameter to the getAttribute method.Let us see the html code of an element UFSC Notes having a tooltip.Here, the tooltip text displayed from UPSC Notes is UPSC IAS Exams Notes -TutorialsPoint which is the value set for the title attribute.SyntaxWebElement l = driver.findElement(By.linkText("UPSC Notes")); String a = ... Read More

How to capture tooltip in Selenium using Actions Class?

Debomita Bhattacharjee
Updated on 06-Apr-2021 10:36:38

602 Views

We can capture the tooltip on an element in Selenium using the Actions class. First, we shall have to create an object of the Actions class and then apply moveToElement to it.This method shall move the mouse to the middle of the element for which we want to capture the tooltip followed by the perform method. Finally, we can obtain the tooltip text with the help of the getText method. This technique is used when the element having a tooltip text does not have a title attribute in its html code.SyntaxWebElement m=driver.findElement(By.linkText("Q/A")); Actions a = new Actions(driver); a.moveToElement(m).perform();Let us capture ... Read More

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

239 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

628 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

Advertisements