Sunday, October 8, 2017

How to verify tooltip text in selenium ?

To verify the tooltip text first we have to mouse over on that element on which tooltip is coming then read the tooltip by using getAttribute() method.

   


    In above image we will read tooltip of Gallery menu.

    // First we mouse hover on Gallery

      WebElement element = driver.findElement(By.xpath("xpath of Gallery"));
      Action act = new Actions(driver);
      act.moveToElement(element).build().perform();

   // Read tooltip and store in a string

      String tooltip_text = element.getAttribute("title"); // In title we can found tooltip text i.e see in image html section.

  // Use assert command to verify the tooltip text

      Assert.assertEquals("visitor gallery", tooltip_text);






                                    How to handle web based popup with Selenium







No comments:

Post a Comment