Articles on Trending Technologies

Technical articles with clear explanations and examples

Is navigate method available in Selenium Webdriver with Python?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 06-Apr-2021 964 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
Debomita Bhattacharjee
Updated on 06-Apr-2021 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
Debomita Bhattacharjee
Updated on 06-Apr-2021 4K+ 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
Debomita Bhattacharjee
Updated on 06-Apr-2021 6K+ 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 run Selenium tests on Internet Explorer browser?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 06-Apr-2021 406 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
Debomita Bhattacharjee
Updated on 06-Apr-2021 779 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
Debomita Bhattacharjee
Updated on 06-Apr-2021 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
Debomita Bhattacharjee
Updated on 06-Apr-2021 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

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

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 06-Apr-2021 3K+ 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 close active/current tab without closing the browser in Selenium-Python?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 06-Apr-2021 16K+ Views

We can close the active/current tab without closing the browser in Selenium webdriver in Python. By default, Selenium has control over the parent window. Once another browser window is opened, we have to explicitly shift the control with the help of switch_to.window method.The handle id of the browser window where we want to shift is passed as a parameter to that method. The method window_handles returns the list of all window handle ids of the opened browsers.The method current_window_handle is used to hold the window handle id of the browser window in focus. To close only the active or current ...

Read More
Showing 49941–49950 of 61,297 articles
Advertisements