In this video, I have explained about how we can handle tooltip in Selenium WebDriver.
Example :
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
Actions actions = new Actions(driver);
WebElement tooltipOnButton = driver.findElement(By.id("toolTipButton"));
actions.moveToElement(tooltipOnButton).build().perform();
wait.until(ExpectedConditions.presenceOfElementLocated(
By.xpath("//*[text()='You hovered over the Button']")));
WebElement tooltipTextOnButton =
driver.findElement(By.xpath("//*[text()='You hovered over the Button']"));
String tooltipText = tooltipTextOnButton.getText();
System.out.println(tooltipText);
WebElement tooltipTextOnInputField = driver.findElement(By.id("toolTipTextField"));
actions.moveToElement(tooltipTextOnInputField).build().perform();
wait.until(ExpectedConditions.presenceOfElementLocated(
By.xpath("//*[text()='You hovered over the text field']")));
WebElement tooltipTextInputField =
driver.findElement(By.xpath("//*[text()='You hovered over the text field']"));
String tooltipText1 = tooltipTextInputField.getText();
System.out.println(tooltipText1);
WebElement tooltipOnAnchorTag = driver.findElement(By.xpath("//*[text()='Contrary']"));
actions.moveToElement(tooltipOnAnchorTag).build().perform();
wait.until(ExpectedConditions.presenceOfElementLocated(
By.xpath("//*[text()='You hovered over the Contrary']")));
WebElement tooltipTextAnchorTag =
driver.findElement(By.xpath("//*[text()='You hovered over the Contrary']"));
String tooltipText2 = tooltipTextAnchorTag.getText();
System.out.println(tooltipText2);
***** Methods we will be using *****
1) moveToElement(element): of Actions class is used to mouse hover an element.
2) Build(): method of Actions class builds the sequence of user actions into an Action object.
3) Perform(): of Action class executes all the sequence of user actions at once.
4) getText(): to get the tooltip text.
In questa pagina del sito puoi guardare il video online How to Handle Tooltip in Selenium WebDriver | Selenium - Java della durata di ore minuti seconda in buona qualità , che l'utente ha caricato CodeWithAvadoot 14 marzo 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 688 volte e gli è piaciuto 9 spettatori. Buona visione!