1

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

waitElement.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\'map\']/div/div/div[1]/div[4]/div[4]/div[2]/div[2]/div[1]/div/a")));

        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"));

        waitElement.until(ExpectedConditions.elementToBeClickable(By.linkText("XYZ")));


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

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.MoveToElement(element6).Perform();
Thread.Sleep(4000);
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
0

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'? – Avtar Krishna Jha Mar 23 '17 at 10:19
  • If you could paste a screenshot of the anchor tag, I might be able to help you. – Avtar Krishna Jha 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")) – Avtar Krishna Jha 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