Hi!
For a couple of days I've been trying to use Selenium to automate testing of a website. This fails because of a hidden menu item that is only displayed when the parent item in the menu is hovered.
The website I'm trying to test on is found here: http://www.sweetarabia ns.com/.
The parent menu item is "Stallions" , which is contained in a HTML LI item. This is also the item to be hovered.
Here is my C# code being used:
This doesn't make the submenu appear at all and I don't understand what I'm doing wrong. Does anybody have a clue? Any help is appreciated.
Best regards
David
For a couple of days I've been trying to use Selenium to automate testing of a website. This fails because of a hidden menu item that is only displayed when the parent item in the menu is hovered.
The website I'm trying to test on is found here: http://www.sweetarabia ns.com/.
The parent menu item is "Stallions" , which is contained in a HTML LI item. This is also the item to be hovered.
Here is my C# code being used:
Code:
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Interactions;
using OpenQA.Selenium.Interactions.Internal;
using OpenQA.Selenium.Support.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Selenium
{
[TestFixture]
public partial class Default : System.Web.UI.Page
{
public Int16 SweetArabians1()
{
Int16 result;
IWebDriver ff_driver = new FirefoxDriver();
ff_driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 30));
ff_driver.Navigate().GoToUrl("http://www.sweetarabians.com/");
var stallions_li = ff_driver.FindElement(By.ClassName("page-item-6"));
Actions action1 = new Actions(ff_driver);
action1.MoveToElement(stallions_li).Perform();
var stallions_link = stallions_li.FindElement(By.LinkText("Stallions"));
Actions action2 = new Actions(ff_driver);
action2.MoveToElement(stallions_link).Perform();
WebDriverWait wait = new WebDriverWait(ff_driver, TimeSpan.FromSeconds(10));
var hero_link = wait.Until((d) => { return d.FindElement(By.LinkText("Sweet Hero")); });
ff_driver.FindElement(By.LinkText("Sweet Hero")).Click();
# Wait a few seconds and then do some testing of the to-be-loaded page here...
if (ff_driver != null)
{
ff_driver.Close();
};
}
protected void Page_Load(object sender, EventArgs e)
{
SweetArabians1();
}
}
}
Best regards
David
Comment