user2401863
user2401863

Reputation: 104

Selenium Webdriver: Can i have mouse over action using href?

My code

class="dropdown-toggle doTransition ng-binding"
    ng-mouseenter="recentList(null,key,0)"
    ng-click="ga('send', 'event', 'Menu', 'Click', topNav.title);"
    href="/television">

class="dropdown-toggle doTransition ng-binding"
    ng-mouseenter="recentList(null,key,0)"
    ng-click="ga('send', 'event', 'Menu', 'Click', topNav.title);"
    href="/bollywood">

I want to have a mouse over action using href. Can anyone suggest me what can be done? Is XPath the only way you can find element?

Upvotes: 0

Views: 726

Answers (2)

Andrew Regan
Andrew Regan

Reputation: 5113

Is XPath the only way you can find element?

The By class shows you can find elements by:

  • class name
  • CSS selector
  • id (attribute)
  • link text (full or partial)
  • name attribute
  • HTML tag name
  • XPath query

Upvotes: 0

Guy
Guy

Reputation: 50819

You can use cssSelector to find the element and Actions to do the hovering

C# code, syntax is similar in all languages

IWebElement element = driver.FindElement(By.CssSelector("[href*='television']"));
Actions actions = new Actions(driver);
actions.MoveToElement(element).Build().Perform();

element will be an web element witch contains "television" in its href

Upvotes: 1

Related Questions