0

Host machine: Windows 10 with VS 2017, Selenium (.NET) & SpecFlow+

I've got a Mojave MacOS with Safari v12 on the network that I need to run my test scripts on. I'm running Selenium C# scripts on it using RemoteWebDriver but they are failing because v12 uses the latest W3C protocols. SafariDriver can be started using the "--legacy" switch. SafariDriverService has a "UseLegacyProtocol" but can't be passed in RemoteWebDriver (example below). Is there a way to activate the switch by: a) Passing it through RemoteWebDriver? b) Merging it as a capability with the options and passing it through RemoteWebDriver? c) Configuring the switch in a json file for use with Selenium Grid v3?

This is to work with C# code.

Code examples I already have:

var sOptions = new SafariOptions();
sOptions.Proxy = null;
var sService = SafariDriverService.CreateDefaultService();
sService.Port = xxxx;
sService.UseLegacyProtocol = true;
Browser = new SafariDriver(sService, sOptions,
TimeSpan.FromSeconds(PageTimeout));

var rOptions = new SafariOptions();    
Browser = new RemoteWebDriver(new Uri("http://xx.xxx.xx.xx:xxxx/wd/hub"), rOptions);

Thanks

faisalk
  • 129
  • 1
  • 14
  • Why do you assign two different drivers to Browser? Why not just use the SafariDriver that you assign first? – mason Nov 06 '18 at 13:33
  • I'm not assigning two different drivers, i'm just showing you the code examples. The first example is just showing that SafariDriverService has an option to use legacy, but SafariDriverService can't be passed in RemoteWebDriver, only SafariDriver. – faisalk Nov 06 '18 at 15:27
  • I don't know what you mean by "SafariDriverService can't be passed in RemoteWebDriver". That doesn't make sense. SafariDriver inherits from RemoteWebDriver, and SafariDriver has a constructor that takes a SafariDriverService. There's no need to directly try to create a RemoteWebDriver. Just remove your last two lines of code and it should work. – mason Nov 06 '18 at 16:02
  • I'm writing the code using Visual Studio on a Windows machine. I cannot run the code locally on the MacOS. Therefore I either need to use RemoteWebDriver with selenium-server or selenium-server-standalone (Grid) – faisalk Nov 07 '18 at 11:52
  • You are missing the point of what I'm saying. SafariDriver is a RemoteWebDriver. It inherits from RemoteWebDriver, therefore it is a RemoteWebDriver. You can remove the last two lines of code you've shown and it should work. Did you try it? What error did you get? Please pay attention to these comments so I don't have to repeat myself. – mason Nov 07 '18 at 13:15
  • It looks like we're getting our wires crossed. I have my local pc which is a Windows 10 pc. I am using VS2017 with C#, Selenium .Net & SpecFlow. The MacOS is another machine on the network with it's own IP address. I cannot run SafariDriver on a Windows machine. I have to run it on the Mac using RemoteWebDriver with an **Uri**. I cannot host the code on the Mac machine. Does this make sense? – faisalk Nov 07 '18 at 13:39
  • Yes, and you should add that to your question. – mason Nov 07 '18 at 14:26
  • I was hoping the words "C" and "sharp" would've been enough ;o) – faisalk Nov 07 '18 at 14:38
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/183244/discussion-between-faisalk-and-mason). – faisalk Nov 07 '18 at 15:08

2 Answers2

0

You can use the following code to merge the capabilities into the SafariOptions:

SafariOptions options = new SafariOptions();
            options.merge(capabilities);

But there is still a bug, Safaridriver can't handle Proxy, it is still an open ticket in there backlog.

0

Legacy protocol is no longer supported in shipping versions of Safari/safaridriver, so I think this question can be closed.

Brian Burg
  • 795
  • 4
  • 10