Now I'm in stuck, because identify the locators I want to click on the google map info window . I tried to do linktext but the linktext not working as expected. it shows an error like

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"link text","selector":"XYZ"}

<div><a href="javascript:void(0);" class="nodecoration" alt="132">XYZ</a></div>

the 'XYZ' is an info window title on google map


        MobileElement element5 =(MobileElement) driver.findElement(By.xpath("//*[@id=\'map\']/div/div/div[1]/div[4]/div[4]/div[2]/div[2]/div[1]/div/a"));


        MobileElement element6 =  element5.findElement(By.linkText("XYZ"));

Locate the parent element of the Element you want to locate and click. Then try to find the desired element with the help of parent element:

WebElement desiredElm = parentElm.findelement(By.linkText("XYZ")).Click();

Or use actions:

Actions action3 = new Actions(Setup.driver);
action3.Click( element6).Perform();
  • I tried to put the above code, but still got the error. Can you see my question i edied
    – user24314
    Mar 23 '17 at 9:54

This is happening because you are trying to locate a non-hyperlink element element using linkText. Try locating the element using the code below -

 waitElement.until(ExpectedConditions.elementToBeClickable(By.Xpath(//div[@title ='General Hospital Ernakulam')));

Note: linkText and partialLinktext work only for elements with HTML tag "a".

  • Actually there is a anchor tag inside that div..
    – user24314
    Mar 23 '17 at 10:16
  • You can identify that element with linkText. But does the link text for that element is 'General Hospital Ernakulam'? Mar 23 '17 at 10:19
  • If you could paste a screenshot of the anchor tag, I might be able to help you. Mar 23 '17 at 10:20
  • Please see the edited question..
    – user24314
    Mar 23 '17 at 10:32
  • Try -waitElement.until(ExpectedConditions.elementToBeClickable(By.Xpath("//div[@title ='General Hospital Ernakulam']/a")) Mar 23 '17 at 10:44

Your Answer

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