4

I have a test scenario that is to verify a tooltip text on a particular element so I tried to use a Selenium inbuilt keyword "Mouse Over <xpath>" but this doesn't work though the test is passing.

I also used other keywords such as "Focus <xpath>" and "Simulate <xpath> click" this also seems not working though the test is passing. I am currently testing on Firefox 3.6 browser.

Could someone help me if there is any such keyword that could hover the mouse on the html element to see the tooltip.

enter image description here

My HTML:

<div class="ng-isolate-scope" ng-show="document.showMultipleRolesTooltip > 1" items-list="document.userStudyRoles" fc-multiple-roles-rollover=""> 
  <div class="fc-multiple-roles-rollover resizeable-1">
    <div class="ng-binding ng-scope" ng-repeat="item in itemsList">  
      Microbiologist
    </div>
    <div class="ng-binding ng-scope" ng-repeat="item in itemsList"> 
      Extended Site Staff
    </div>
  </div>
</div>
  • can you please show us your code and HTML? – Yu Zhang Mar 5 '17 at 19:38
  • <div class="ng-isolate-scope" ng-show="document.showMultipleRolesTooltip > 1" items-list="document.userStudyRoles" fc-multiple-roles-rollover=""> <div class="fc-multiple-roles-rollover resizeable-1"> <div class="ng-binding ng-scope" ng-repeat="item in itemsList"> Microbiologist </div> <div class="ng-binding ng-scope" ng-repeat="item in itemsList"> Extended Site Staff </div> </div> </div> – sravan Mar 5 '17 at 23:08
  • @YuZhang the code i tried is Mouse Over //div[contains(text(),'Microbiologist')] and Focus //div[contains(text(),'Microbiologist')] – sravan Mar 5 '17 at 23:20
  • Have you tried using other attributes? – Yu Zhang Mar 6 '17 at 2:43
  • I didn't try other attributes – sravan Mar 6 '17 at 9:00
1

Use the Actions class to mouse-over (OpenQA.Selenium.Interactions.Actions)

At this link you will find several methods. Mouse hover action

0

Without using mouse hover also, we can get those tooltip by using the below code.

    String tooltip1 = driver.findElement(By.xpath("//div[@class='fc-multiple-roles-rollover resizeable-1']/div[1]")).getText(); // use to get the first tooltip
    System.out.println(tooltip1);

    String tooltip2 = driver.findElement(By.xpath("//div[@class='fc-multiple-roles-rollover resizeable-1']/div[2]")).getText; // use to get 2nd tooltip
    System.out.println(tooltip2);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.