Debomita Bhattacharjee has Published 863 Articles

How to perform scrolling action on page in Selenium?

Debomita Bhattacharjee

Debomita Bhattacharjee

Updated on 10-Jun-2020 13:44:08

1K+ Views

We can perform the following actions with respect to scrolling in Selenium −Vertical scrollingThe scrolling down to a specific pixel.JavascriptExecutor j = (JavascriptExecutor) driver; // scroll down by 1500 pixel with coordinates 0 and 1500 in x, y axes j.executeScript("window.scrollBy(0, 1500)");The scrolling down to the bottom of the page.JavascriptExecutor j ... Read More

How to extract the attribute value of an element in Selenium?

Debomita Bhattacharjee

Debomita Bhattacharjee

Updated on 10-Jun-2020 13:35:43

1K+ Views

We can extract the attribute value of an element in Selenium with the help of getAttribute() method. Once we locate the element, this method is used to get the attribute value of the element and assigned to a variable.Exampleimport org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; ... Read More

How to press ENTER inside an edit box in Selenium?

Debomita Bhattacharjee

Debomita Bhattacharjee

Updated on 10-Jun-2020 13:34:13

845 Views

Selenium gives Enum Key macros to perform the enter action.Exampleimport org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; import java.util.List; public class PressEnter {    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver driver = new ChromeDriver();       ... Read More

What are the differences between get() and navigate() method?

Debomita Bhattacharjee

Debomita Bhattacharjee

Updated on 10-Jun-2020 13:32:34

9K+ Views

The differences between get() and navigate() methods are listed below.sl.no.get()navigate()1It is responsible for loading the page and waits until the page has finished loading.It is only responsible for redirecting the page and then returning immediately.2It cannot track the history of the browser.It tracks the browser history and can perform back ... Read More

How to perform browser navigations in Selenium?

Debomita Bhattacharjee

Debomita Bhattacharjee

Updated on 10-Jun-2020 13:24:52

630 Views

There are various navigate() methods to perform navigations in Selenium. They are as the listed below −navigate().to(url)This is used to launch a new browser and open a particular URL as in the parameter.navigate().refresh()This is used to reload a page.navigate().back()This is used to jump to the previous page as per browser ... Read More

What are the differences between findElement() and findElements() methods?

Debomita Bhattacharjee

Debomita Bhattacharjee

Updated on 10-Jun-2020 13:19:00

1K+ Views

findElement() and findElements() method tries to search an element in DOM.The differences between them are listed below −sl.no.findElement()findElements()1It returns the first web element which matches with the locator.It returns all the web elements which match with the locator.2Syntax − WebElement button = webdriver.findElement(By.name(""));Syntax − List buttons = webdriver.findElements(By.name(""));3NoSuchElementException is thrown ... Read More

What is xpath in Selenium?

Debomita Bhattacharjee

Debomita Bhattacharjee

Updated on 10-Jun-2020 13:13:52

3K+ Views

Xpath is one of the most important locators used in Selenium for identifying web elements. It works in the following ways −It navigates through the Document Object Model (DOM) with the help of elements and their attributes for identification.Although it helps to locate the elements uniquely, it is slower in ... Read More

What are the different methods of creating a css expression?

Debomita Bhattacharjee

Debomita Bhattacharjee

Updated on 10-Jun-2020 13:09:03

256 Views

The different methods of creating a css expression are listed below −Using a class as css selectorThis will select all the web elements of that particular class. (Represented by (.) for example - .classname)Using an id as css selector.This will select the web element of that particular id. (Represented by ... Read More

How to identify the nth sub element using xpath?

Debomita Bhattacharjee

Debomita Bhattacharjee

Updated on 10-Jun-2020 13:06:19

7K+ Views

We can identify the nth sub element using xpath in the following ways −By adding square brackets with index.By using position () method in xpath.Exampleimport org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class SubElement {    public static void main(String[] args) {       ... Read More

Among id, name, xpath and css, which locator should be used?

Debomita Bhattacharjee

Debomita Bhattacharjee

Updated on 10-Jun-2020 13:04:03

387 Views

Each of the locators has some significance. If the page contains uniqueattribute values, we should use them first. However if there are no unique elements, we should use css selector as it is more effective in terms of speed.Css also has a drawback that we cannot traverse from child to ... Read More

Advertisements