Skip to content

Commit

Permalink
Added editable arguments to Selenium ChromeDriver options
Browse files Browse the repository at this point in the history
  • Loading branch information
VirtualFab committed Jun 5, 2019
1 parent 3ba5a3c commit 2091b86
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions taskt/Core/Automation/Commands/SeleniumBrowserCreateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ public class SeleniumBrowserCreateCommand : ScriptCommand
[Attributes.PropertyAttributes.Remarks("")]
public string v_BrowserWindowOption { get; set; }

[XmlAttribute]
[Attributes.PropertyAttributes.PropertyDescription("Please specify Selenium command line options (optional)")]
[Attributes.PropertyAttributes.InputSpecification("Select optional options to be passed to the Selenium command.")]
[Attributes.PropertyAttributes.SampleUsage("user-data-dir=/user/public/SeleniumTasktProfile")]
[Attributes.PropertyAttributes.Remarks("")]
public string v_SeleniumOptions { get; set; }

[XmlAttribute]
[Attributes.PropertyAttributes.PropertyDescription("Please Select a Browser Engine Type")]
[Attributes.PropertyAttributes.PropertyUISelectionOption("Chrome")]
Expand Down Expand Up @@ -71,13 +78,20 @@ public override void RunCommand(object sender)

if (seleniumEngine == "Chrome")
{
OpenQA.Selenium.Chrome.ChromeOptions options = new OpenQA.Selenium.Chrome.ChromeOptions();

if (!string.IsNullOrEmpty(v_SeleniumOptions))
{
options.AddArguments(v_SeleniumOptions);
}

driverService = OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService(driverPath);
webDriver = new OpenQA.Selenium.Chrome.ChromeDriver((OpenQA.Selenium.Chrome.ChromeDriverService)driverService, new OpenQA.Selenium.Chrome.ChromeOptions());
webDriver = new OpenQA.Selenium.Chrome.ChromeDriver((OpenQA.Selenium.Chrome.ChromeDriverService)driverService, options);
}
else
{
driverService = OpenQA.Selenium.IE.InternetExplorerDriverService.CreateDefaultService(driverPath);
webDriver = new OpenQA.Selenium.IE.InternetExplorerDriver((OpenQA.Selenium.IE.InternetExplorerDriverService)driverService, new OpenQA.Selenium.IE.InternetExplorerOptions());
webDriver = new OpenQA.Selenium.IE.InternetExplorerDriver((OpenQA.Selenium.IE.InternetExplorerDriverService)driverService, new OpenQA.Selenium.IE.InternetExplorerOptions());
}


Expand Down Expand Up @@ -110,13 +124,14 @@ public override void RunCommand(object sender)
}
public override List<Control> Render(frmCommandEditor editor)
{
base.Render(editor);

base.Render(editor);


RenderedControls.AddRange(CommandControls.CreateDefaultInputGroupFor("v_InstanceName", this, editor));
RenderedControls.AddRange(CommandControls.CreateDefaultDropdownGroupFor("v_EngineType", this, editor));
RenderedControls.AddRange(CommandControls.CreateDefaultDropdownGroupFor("v_InstanceTracking", this, editor));
RenderedControls.AddRange(CommandControls.CreateDefaultDropdownGroupFor("v_BrowserWindowOption", this, editor));
RenderedControls.AddRange(CommandControls.CreateDefaultInputGroupFor("v_SeleniumOptions", this, editor));

return RenderedControls;
}
Expand Down

0 comments on commit 2091b86

Please sign in to comment.