Ans. Using driver.navigate().refresh() command. Using sendKeys(Keys.F5) on any textbox on the webpage. Using driver.get(“URL”) on the current URL or using driver.getCurrentUrl() Using driver.navigate().to(“URL”) on the current URL or
driver.navigate().to(driver.getCurrentUrl());
Ans. findElement() returns a single WebElement (found first) based on the locator passed as a parameter. Whereas findElements() returns a list of WebElements, all satisfying the locator value passed.
Another difference between the two is if no element is found then findElement() throws NoSuchElementException whereas findElements() returns a list of 0 elements.
Ans. The driver.getWindowHandle() returns a handle of the current window (a single unique identifier). Whereas driver.getWindowHandles() returns a set of handles of all the windows available.
Ans. A relative XPath is a way of locating an element using an XML expression, starting from anywhere in the HTML document. In this way, there are different ways of creating robust relative XPaths that are unaffected by changes in other UI elements. Example - //input[@id='username']
Ans. Yes, using driver.navigate().back() and driver.navigate().forward() commands, we can move backward and forward in a browser.
Ans. Actions action = new Actions(driver); WebElement element=driver.findElement(By.id("elementId")); action.doubleClick(element).perform();
Ans. Desired capabilities are a set of key-value pairs that are used for storing or configuring browser-specific properties. For example - browser's version, platform, etc in the browser instances.
Ans. All the links are of anchor tag 'a'. So by locating elements of tagName 'a' we can find all the links on a webpage. List<WebElement> links = driver.findElements(By.tagName("a"));
Ans. Page Object Model(POM) is a design pattern in Selenium. A design pattern is a solution or a set of standards that are used for solving commonly occurring software problems.
Now coming to POM – POM helps to create a framework for maintaining selenium scripts. In POM for each page of the application, a class is created having the web elements belonging to the page and methods handling the events on that page. The test scripts are maintained in separate files and the methods of the page object files are called from the test scripts file.