My requirement is verifying Image Hover is working or not using Webdriver. In that image tag title value is changing when I mouseover on the image like below.
Normal:
[img title="ASPIRIN" "src="http://img.med.com/pi/LNK01570.jpg" class="preview">
if i mouseover on that image:[img title="" "src="http://img.med.com/pi/LNK01570.jpg" class="preview">
So here I'm trying to compare title values to verify the image hover. I have written code for that and it is working fine when I execute the script without using Grid. But using Grid mouseOver is not working properly. Image tag values aren't being changed. Is there any issue with using Grid? I'm using FF17 and Selenium 2.28.0 and Selenium 2.25.0.
My code:
String strVal1 = driver.findElement(By.xpath("//table[@id='ref_priceimgtable']/tbody/tr[12]/td[4]/img")).getAttribute("title");
System.out.println(strVal1);
WebElement element = driver.findElement(By.xpath("//table[@id='ref_priceimgtable']/tbody/tr[12]/td[4]/img"));
Locatable hoverItem = (Locatable) element;
hoverItem.getLocationOnScreenOnceScrolledIntoView();
Mouse mouse = ((HasInputDevices) driver).getMouse();
mouse.mouseMove(hoverItem.getCoordinates());
String strVal2 = driver.findElement(By.xpath("//table[@id='ref_priceimgtable']/tbody/tr[12]/td[4]/img")).getAttribute("title");
System.out.println(strVal1+"Null Value");
In the above code strVal1
and strVal2
should be different.