Found 719 Articles for Testing Tools

How to Select Value from DropDown using Selenium Webdriver?

Debomita Bhattacharjee
Updated on 06-Apr-2021 10:54:24

7K+ Views

We can select an option from the dropdown with its value attribute in Selenium webdriver by using the Select class. . A dropdown is represented by tag and the options are represented by tag.To select an option with its value we have to use the selectByValue method and pass the value attribute of the option that we want to select as a parameter to that method.SyntaxWebElement v = driver.findElement(By.name("selt")); Select s = new Select(v); s.selectByValue("val1");Let us see the html code of a dropdown having value attribute for its options.Exampleimport 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; ... Read More

How to extract text from a web page using Selenium and save it as a text file?

Debomita Bhattacharjee
Updated on 06-Apr-2021 10:52:47

4K+ Views

We can extract text from a webpage using Selenium webdriver and save it as a text file using the getText method. It can extract the text for an element which is displayed (and not hidden by CSS).We have to locate the element on the page using any of the locators like id, class, name, xpath, css, tag name, link text or partial link text. Once the text is obtained, we shall write its content to a file with the help of File class.Let us obtain the text – You are browsing the best resource for Online Education from the below ... Read More

Is it possible to manually set the attribute value of a Web Element using Selenium?

Debomita Bhattacharjee
Updated on 06-Apr-2021 10:49:31

3K+ Views

Yes it is possible to manually set the attribute value of a web element in Selenium webdriver using the JavaScript Executor. Selenium can run JavaScript commands with the help of the executeScript method.First, we shall identify the element on which we want to manually set the attribute value with the JavaScript command document.getElementsByClassname. Next to set the attribute we have to use the setAttribute method.Let us modify the background color of the button CHECK IT NOW to yellow. By default it is green on the page.The can be done by setting the style attribute of the background-color to yellow.SyntaxJavascriptExecutor j ... Read More

How to install TestNG in eclipse using Selenium?

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

412 Views

We can install TestNG in Eclipse to create a test automation framework with the help of the following steps −First, we have to launch the Eclipse editor, click the menu Help, and then choose Eclipse Marketplace.The Eclipse Marketplace pop-up shall come up, enter TestNG in the search box and click on Go. Once the search result – TestNG for Eclipse gets populated at the top, click on Install.After some time, the confirm Selected Features window comes up, check the TestNG for Eclipse and proceed.Choose the radio button - Keep my installation the same, then click on Confirm.Next, we have to ... Read More

Is navigate method available in Selenium Webdriver with Python?

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

545 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

470 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

613 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

Advertisements