Discussion:
[specflow] Unable to perform the action.movetoElement(<element>).click(<element2>).Build().Perform() operation in SpecFlow
Swati Gupta
2018-04-25 09:40:20 UTC
Permalink
if (jobStatus.Equals("ALLOCATED"))
{
IWebElement elementToHover =
rowList.FindElement(By.CssSelector("td:nth-child(2)"));
IWebElement elementToClick =
rowList.FindElement(By.CssSelector("td:nth-child(2) > div > i"));
Actions action = new Actions(_driver);

action.MoveToElement(elementToHover).Click(elementToClick).Build().Perform();
break;
}
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Andreas Willich
2018-04-25 10:36:28 UTC
Permalink
Hi

It looks like you have more of a problem with Selenium as with SpecFlow.
So I would suggest to ask at Selenium or at Stack Overflow for help for
your problem.

regards,
Andreas
Post by Swati Gupta
if (jobStatus.Equals("ALLOCATED"))
{
IWebElement elementToHover =
rowList.FindElement(By.CssSelector("td:nth-child(2)"));
IWebElement elementToClick =
rowList.FindElement(By.CssSelector("td:nth-child(2) > div > i"));
Actions action = new Actions(_driver);
action.MoveToElement(elementToHover).Click(elementToClick).Build().Perform();
break;
}
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Swati Gupta
2018-04-25 13:41:53 UTC
Permalink
Its working fine in Selenium but not working with specflow
getting error:

///////////////////////////////////
'action.MoveToElement(elementToHover).Build().Perform()' threw an exception
of type 'System.InvalidOperationException'
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233079
HelpLink: null
InnerException: null
Message: "performActions"
Source: "WebDriver"
StackTrace: " at
OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
errorResponse)\r\n at
OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
driverCommandToExecute, Dictionary`2 parameters)\r\n at
OpenQA.Selenium.Remote.RemoteWebDriver.PerformActions(IList`1
actionSequenceList)\r\n at OpenQA.Selenium.Interactions.Actions.Perform()"
TargetSite: {Void
UnpackAndThrowOnError(OpenQA.Selenium.Remote.Response)}

////////////////////////////////////////////
Post by Swati Gupta
if (jobStatus.Equals("ALLOCATED"))
{
IWebElement elementToHover =
rowList.FindElement(By.CssSelector("td:nth-child(2)"));
IWebElement elementToClick =
rowList.FindElement(By.CssSelector("td:nth-child(2) > div > i"));
Actions action = new Actions(_driver);
action.MoveToElement(elementToHover).Click(elementToClick).Build().Perform();
break;
}
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Vrushali
2018-04-25 14:04:39 UTC
Permalink
Swati be careful when you select proper package (using) for Action
class.Selenium will give you 2 choices to select from mouse hover after
adding action
Another thing is try using DoubleClick or any other option to see if it
works. I dp use it often with specflow
Post by Swati Gupta
Its working fine in Selenium but not working with specflow
///////////////////////////////////
'action.MoveToElement(elementToHover).Build().Perform()' threw an
exception of type 'System.InvalidOperationException'
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233079
HelpLink: null
InnerException: null
Message: "performActions"
Source: "WebDriver"
StackTrace: " at
OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
errorResponse)\r\n at
OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
driverCommandToExecute, Dictionary`2 parameters)\r\n at
OpenQA.Selenium.Remote.RemoteWebDriver.PerformActions(IList`1
actionSequenceList)\r\n at OpenQA.Selenium.Interactions.Actions.Perform()"
TargetSite: {Void
UnpackAndThrowOnError(OpenQA.Selenium.Remote.Response)}
////////////////////////////////////////////
Post by Swati Gupta
if (jobStatus.Equals("ALLOCATED"))
{
IWebElement elementToHover =
rowList.FindElement(By.CssSelector("td:nth-child(2)"));
IWebElement elementToClick =
rowList.FindElement(By.CssSelector("td:nth-child(2) > div > i"));
Actions action = new Actions(_driver);
action.MoveToElement(elementToHover).Click(elementToClick).Build().Perform();
break;
}
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Swati Gupta
2018-04-25 14:23:09 UTC
Permalink
I tried both:
Below mention code exist in my hook file
Hook.cs
public class Hooks: Base
{
private readonly IObjectContainer _objectContainer;
public Hooks(IObjectContainer objectContainer)
{
try
{
this._objectContainer = objectContainer;
}
catch(Exception ex)
{
Console.WriteLine("Hooks EX: " + ex.Message);
}

}
/// <summary>
/// Execute the code before every Scenario
/// </summary>
[BeforeScenario]
public void InitializeFirefox()
{
try
{
SelectBrowser(BrowserType.Firefox);
}
catch (Exception ex)
{
Console.WriteLine("Initialize EX: " + ex.Message);
}
}

/// <summary>
/// Execute the code after every Scenario
/// </summary>
[AfterScenario]
public void CleanUp()
{
try
{
_driver.Quit();
}
catch (Exception ex)
{
Console.WriteLine(" CleanUp EX: " + ex.Message);
}
}

/// <summary>
/// Browser Selection code
/// </summary>
/// <param name="browserType"></param>
internal void SelectBrowser(BrowserType browserType)
{
try
{
switch (browserType)
{
case BrowserType.Chrome:
_driver = new
ChromeDriver(@"C:\Users\admin.VE-300116_B\Desktop\Gerry\SpecflowSeleniumParallel-master\SpecflowParallelTest\bin\Debug");

_objectContainer.RegisterInstanceAs<IWebDriver>(_driver);
break;
case BrowserType.Firefox:


//string URL =
"https://pickup-dispatch-uat.azurewebsites.net/login";
//string Node = "http://192.168.2.9:5555/wd/hub";
//DesiredCapabilities cap =
DesiredCapabilities.Firefox();

//_driver = new RemoteWebDriver(new Uri(Node), cap);

var driverDir =
System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
FirefoxDriverService service =
FirefoxDriverService.CreateDefaultService(driverDir, "geckodriver.exe");
service.FirefoxBinaryPath = @"C:\Program Files
(x86)\Mozilla Firefox\firefox.exe";
service.HideCommandPromptWindow = true;
service.SuppressInitialDiagnosticInformation = true;
_driver = new FirefoxDriver(service);

_objectContainer.RegisterInstanceAs<IWebDriver>(_driver);
break;
}

}
catch (Exception ex)
{
Console.WriteLine(" SelectBrowser EX: " + ex.Message);
}
}

}

enum BrowserType
{
Chrome,
Firefox
}


step.cs
[Then(@"Perform Cancel Operation on Allocated Pickup")]
public void PerformCancelOperationonAllocatedPickup()
{
try
{
LoginPage page = new LoginPage(_driver);
IReadOnlyList<IWebElement> rowsLists =
_driver.FindElements(By.CssSelector(".pd-Pickups-accordions
pd-accordion-group:nth-child(2) pd-pickups-grid table tbody tr"));
foreach (IWebElement rowList in rowsLists)
{
var jobStatus =
rowList.FindElement(By.CssSelector("td:nth-child(4)")).Text;
if (jobStatus.Equals("ALLOCATED"))
{
IWebElement elementToHover =
rowList.FindElement(By.CssSelector("td:nth-child(2)"));
IWebElement elementToClick =
rowList.FindElement(By.CssSelector("td:nth-child(2) > div"));
Actions action = new Actions(_driver);


action.MoveToElement(elementToHover).Click(elementToClick).Build().Perform();
break;
}
}

page.AllocateToCancelPickup(pickupJobId);
}
catch (Exception ex)
{
Console.WriteLine("PerformCancelOperationonAllocatedPickup
:" + ex.StackTrace);
}
}
Post by Vrushali
Swati be careful when you select proper package (using) for Action
class.Selenium will give you 2 choices to select from mouse hover after
adding action
Another thing is try using DoubleClick or any other option to see if it
works. I dp use it often with specflow
Post by Swati Gupta
Its working fine in Selenium but not working with specflow
///////////////////////////////////
'action.MoveToElement(elementToHover).Build().Perform()' threw an
exception of type 'System.InvalidOperationException'
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233079
HelpLink: null
InnerException: null
Message: "performActions"
Source: "WebDriver"
StackTrace: " at
OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
errorResponse)\r\n at
OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
driverCommandToExecute, Dictionary`2 parameters)\r\n at
OpenQA.Selenium.Remote.RemoteWebDriver.PerformActions(IList`1
actionSequenceList)\r\n at OpenQA.Selenium.Interactions.Actions.Perform()"
TargetSite: {Void
UnpackAndThrowOnError(OpenQA.Selenium.Remote.Response)}
////////////////////////////////////////////
Post by Swati Gupta
if (jobStatus.Equals("ALLOCATED"))
{
IWebElement elementToHover =
rowList.FindElement(By.CssSelector("td:nth-child(2)"));
IWebElement elementToClick =
rowList.FindElement(By.CssSelector("td:nth-child(2) > div > i"));
Actions action = new Actions(_driver);
action.MoveToElement(elementToHover).Click(elementToClick).Build().Perform();
break;
}
--
You received this message because you are subscribed to the Google Groups
"SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...