diff --git a/FluentAutomation.SeleniumWebDriver/CommandProvider.cs b/FluentAutomation.SeleniumWebDriver/CommandProvider.cs
index c60c6f6..d223b05 100644
--- a/FluentAutomation.SeleniumWebDriver/CommandProvider.cs
+++ b/FluentAutomation.SeleniumWebDriver/CommandProvider.cs
@@ -251,6 +251,15 @@ public void DoubleClick(ElementProxy element)
});
}
+ public void ExecuteJavaScript(string script)
+ {
+ this.Act(CommandType.Action, false, () =>
+ {
+ var jsExec = this.webDriver as IJavaScriptExecutor;
+ jsExec.ExecuteScript(script);
+ });
+ }
+
public void RightClick(int x, int y)
{
this.Act(CommandType.Action, () =>
diff --git a/FluentAutomation.SeleniumWebDriver/MultiCommandProvider.cs b/FluentAutomation.SeleniumWebDriver/MultiCommandProvider.cs
index e05b659..641bd8e 100644
--- a/FluentAutomation.SeleniumWebDriver/MultiCommandProvider.cs
+++ b/FluentAutomation.SeleniumWebDriver/MultiCommandProvider.cs
@@ -88,6 +88,11 @@ public void DoubleClick(ElementProxy element, int x, int y)
public void DoubleClick(ElementProxy element)
{
this.RepackExceptions(() => Parallel.ForEach(element.Elements, e => e.Item1.DoubleClick(new ElementProxy(e.Item1, e.Item2))));
+ }
+
+ public void ExecuteJavaScript(string script)
+ {
+ this.RepackExceptions(() => Parallel.ForEach(this.commandProviders, xx => xx.ExecuteJavaScript(script)));
}
public void RightClick(int x, int y)
diff --git a/FluentAutomation.WatiN/CommandProvider.cs b/FluentAutomation.WatiN/CommandProvider.cs
index 9121e9d..cddcb62 100644
--- a/FluentAutomation.WatiN/CommandProvider.cs
+++ b/FluentAutomation.WatiN/CommandProvider.cs
@@ -233,6 +233,14 @@ public void DoubleClick(ElementProxy element)
this.ActiveDomContainer.Eval(string.Format("if (typeof jQuery != 'undefined') {{ jQuery({0}).dblclick(); }}", el.AutomationElement.GetJavascriptElementReference()));
});
}
+
+ public void ExecuteJavaScript(string script)
+ {
+ this.Act(CommandType.Action, false, () =>
+ {
+ this.browser.Eval(script);
+ });
+ }
public void RightClick(int x, int y)
{
diff --git a/FluentAutomation/ActionSyntaxProvider.cs b/FluentAutomation/ActionSyntaxProvider.cs
index 8e73dad..1158550 100644
--- a/FluentAutomation/ActionSyntaxProvider.cs
+++ b/FluentAutomation/ActionSyntaxProvider.cs
@@ -94,6 +94,12 @@ public IActionSyntaxProvider Click(Alert alertAccessor)
return this;
}
+ public IActionSyntaxProvider ExecuteJavaScript(string script)
+ {
+ this.commandProvider.ExecuteJavaScript(script);
+ return this;
+ }
+
public IActionSyntaxProvider Scroll(int x, int y)
{
this.commandProvider.Hover(x, y);
diff --git a/FluentAutomation/BaseCommandProvider.cs b/FluentAutomation/BaseCommandProvider.cs
index 8c5e5dc..27592f5 100644
--- a/FluentAutomation/BaseCommandProvider.cs
+++ b/FluentAutomation/BaseCommandProvider.cs
@@ -51,11 +51,16 @@ private void FireExpectFailed()
}
public void Act(CommandType commandType, Action action)
+ {
+ this.Act(commandType, this.WaitOnAction(commandType), action);
+ }
+
+ protected void Act(CommandType commandType, bool waitOnAction, Action action)
{
bool originalWaitOnActions = this.Settings.WaitOnAllActions;
try
{
- if (this.WaitOnAction(commandType))
+ if (waitOnAction)
{
this.WaitUntil(() => action(), this.Settings.WaitUntilTimeout);
}
diff --git a/FluentAutomation/Interfaces/IActionSyntaxProvider.cs b/FluentAutomation/Interfaces/IActionSyntaxProvider.cs
index fd8576f..81db6bc 100644
--- a/FluentAutomation/Interfaces/IActionSyntaxProvider.cs
+++ b/FluentAutomation/Interfaces/IActionSyntaxProvider.cs
@@ -228,6 +228,13 @@ public interface IActionSyntaxProvider : ISyntaxProvider
/// Y-coordinate offset.
IActionSyntaxProvider DoubleClick(string selector, int x, int y);
+ ///
+ /// Executes a script.
+ ///
+ /// The script.
+ ///
+ IActionSyntaxProvider ExecuteJavaScript(string script);
+
///
/// RightClick at the specified coordinates.
///
diff --git a/FluentAutomation/Interfaces/ICommandProvider.cs b/FluentAutomation/Interfaces/ICommandProvider.cs
index 9ee1d0c..6bffd3a 100644
--- a/FluentAutomation/Interfaces/ICommandProvider.cs
+++ b/FluentAutomation/Interfaces/ICommandProvider.cs
@@ -72,8 +72,8 @@ public interface ICommandProvider : IDisposable
void AlertClick(Alert accessor);
void AlertText(Action matchFunc);
void AlertEnterText(string text);
- void Visible(ElementProxy element, Action action);
-
+ void Visible(ElementProxy element, Action action);
+ void ExecuteJavaScript(string script);
void CssPropertyValue(ElementProxy element, string propertyName, Action action);
void Act(CommandType commandType, Action action);
diff --git a/FluentAutomation/Properties/AssemblyGlobal.cs b/FluentAutomation/Properties/AssemblyGlobal.cs
index 9188064..c1fe283 100644
--- a/FluentAutomation/Properties/AssemblyGlobal.cs
+++ b/FluentAutomation/Properties/AssemblyGlobal.cs
@@ -9,4 +9,4 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
-[assembly: AssemblyVersion("3.0.1.0")]
\ No newline at end of file
+[assembly: AssemblyVersion("3.0.2.0")]
\ No newline at end of file