1

enter image description here

Hi, I am trying to locate and click on the element that comes up in the search box when I type some name. Can someone please help me out to find & click on the name? I've use searching by XPath - contains(@class, '...'); contains(text()) etc, but everytime it fails.

When I inspect the element, I see this HTML: enter image description here

1
  • Never mind! Got my own solution. Thanks for help!! Commented Nov 8, 2018 at 17:15

1 Answer 1

1

Use Action class and move to the search suggestions element first then perform your action.

Actions action = new Action(driver);
action.MoveToElement("Locator of the element").Perform();

Use the above method to try accessing the search suggestion element.

3
  • I tried it but the focus is shifted to the 'Overview' section - top left. I did this: OpenQA.Selenium.Interactions.Actions actions = new OpenQA.Selenium.Interactions.Actions(driver); actions.MoveToElement(driver.FindElement(By.XPath("//span[contains(text(),'Acura West')]"))).Perform(); Can you please help. I'm kinda stuck Commented Nov 8, 2018 at 14:09
  • Verify if there are multiple matches occurs in finding the element or verify the element is present inside the frame Commented Nov 8, 2018 at 16:03
  • I'm trying this: PopupWindowFinder finder = new PopupWindowFinder(driver); String advName = rowValue[0]; IWebElement adv = driver.FindElement(By.XPath("//*[contains(@placeholder, 'Add filter')]")); string popupWindowHandle = finder.Click(adv.SendKeys(advName)); So, the popup only triggers when I type in some text in the 'Add filter' (search box basically) I don't know how to do that using: string popupWindowHandle = finder.Click(adv.SendKeys(advName)); I get an error here 'cannot convert from 'void' to 'OpenQA.Selenium.IWebElement' Commented Nov 8, 2018 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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