Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

.Net set Ghostdriver src property GhostDriverPath causes proxy to be ignored #5999

Closed
lukeis opened this issue Mar 4, 2016 · 4 comments
Closed

Comments

@lukeis
Copy link
Member

lukeis commented Mar 4, 2016

Originally reported on Google Code with ID 5999

Have been mumbling to myself here:
https://code.google.com/p/selenium/source/detail?r=93acf0798e5b8a93e22fc9d20cc84c7faeef38f9

But am posting the issue here as well

The new property  (GhostDriverPath) added in the change (link above) that allows the
specification of the source file of ghostdriver introduces a bug

More details here on why
https://github.com/detro/ghostdriver/issues/202#issuecomment-21382287

The args as passed when using the new property will be
" D:\\path\\to\\src\\main.js --port=58967 --proxy=123.456.789:80"

but this will not work for reasons I do not really understand, however the following
does work.

" --proxy=123.456.789:80 D:\\path\to\\src\\main.js --port=58967 "


Selenium version: Not sure, I downloaded the code from github on about the 20th of
july :-)
OS: Win7
Browser: phantomjs
Browser version: 1.9.1.0

Reported by martinjspeed on 2013-07-25 20:13:46

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

so here is the fix

before the args were set where the 
 bAppendGhostDriver = true;
is now set.




  protected override string CommandLineArguments
        {
            get
            {
                StringBuilder argsBuilder = new StringBuilder();
                bool bAppendGhostDriver = false;
                if (string.IsNullOrEmpty(this.ghostDriverPath))
                {
                    argsBuilder.AppendFormat(CultureInfo.InvariantCulture, " --webdriver={0}",
this.Port);
                    if (!string.IsNullOrEmpty(this.logFile))
                    {
                        argsBuilder.AppendFormat(" --webdriver-logfile={0}", this.logFile);
                    }
                }
                else
                {
                    bAppendGhostDriver = true;
                }

                if (!string.IsNullOrEmpty(this.ConfigFile))
                {
                    argsBuilder.AppendFormat(" --config={0}", this.ConfigFile);
                }
                else
                {
                    var properties = typeof(PhantomJSDriverService).GetProperties();
                    foreach (PropertyInfo info in properties)
                    {
                        if (IsSerializableProperty(info))
                        {
                            object propertyValue = info.GetValue(this, null);
                            object defaultValue = GetPropertyDefaultValue(info);
                            if (propertyValue != null && !propertyValue.Equals(defaultValue))
                            {
                                string argumentName = GetPropertyCommandLineArgName(info);
                                string argumentValue = this.GetPropertyCommandLineArgValue(info);
                                argsBuilder.AppendFormat(" --{0}={1}", argumentName,
argumentValue);
                            }
                        }
                    }
                }

                if (this.additionalArguments.Count > 0)
                {
                    foreach (string additionalArg in this.additionalArguments)
                    {
                        if (!string.IsNullOrEmpty(additionalArg.Trim()))
                        {
                            argsBuilder.AppendFormat(" {0}", additionalArg);
                        }
                    }
                }


                if(bAppendGhostDriver)
                {
                    argsBuilder.AppendFormat(" {0}", this.ghostDriverPath);
                    argsBuilder.AppendFormat(CultureInfo.InvariantCulture, " --port={0}",
this.Port);
                    if (!string.IsNullOrEmpty(this.logFile))
                    {
                        argsBuilder.AppendFormat(" --logFile={0}", this.logFile);
                    }
                }

                return argsBuilder.ToString();
            }
        }

Reported by martinjspeed on 2013-07-25 21:58:20

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Another suggested change

this:
  argsBuilder.AppendFormat(" {0}", this.ghostDriverPath);

to
  argsBuilder.AppendFormat(" {0}", "\""+this.ghostDriverPath + "\"" );

Reported by martinjspeed on 2013-07-27 02:39:24

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

This issue was closed by revision 214cd4513bbe.

Reported by james.h.evans.jr on 2013-07-29 04:12:15

  • Status changed: Fixed

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by luke.semerau on 2015-09-17 18:17:40

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 4, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant