Myself and a co-worker have been playing around with this a bit more. Perhaps we've made some progress, but we are still not where we want to be and perhaps we are running into unsupported items, or bugs, or lack of understanding... Anyway, here's what we are playing with and what is wrong...
What I'd like to accomplish is NOT to use Ranorex Studio to create endpoints. But To continue coding using Ranorex code, not selenium.
First, I found in the VS object browser some information about the RemoteEndpointFactory. Using your sample code provided here in C#, I converted it to VB.NET and wrote this:
(Note: this worked. It launched Chrome on my other machine and navigated to ranorex's website)
Dim sEPURL As String = "http://vmtaclt17-a99:4444/wd/hub"
Dim fac As New Ranorex.Core.RemoteEndpointFactory
Dim ep = fac.CreateTransientWebDriverEndpoint(New WebDriverEndpointInfo("TempEP", sEPURL))
Dim cfg = WebDriverConfiguration.FromJson("{""platform"": ""Windows 8.1"", ""browserName"": ""chrome"", ""version"": ""59.0""}")
'BTW: These next 2 lines both change each other's values. Bug?
cfg.Name = "MyConfig1"
cfg.Description = "Code sample Config"
ep.ActivateConfiguration(cfg)
ep.ConnectAsync().ContinueWith(Sub(antecendent) ep.MakeCurrentHostAsync()).Wait()
Dim b As OpenQA.Selenium.IWebDriver
b = ep.StartBrowser("chrome", "http://www.ranorex.com")
'So now I have a selenium web driver object... but I don't want to code in selenium. I want to code using Ranorex as this is already used throughout my framework.... Maybe I just need a little more info??
OK, code above is part of what I want. Creates dynamic endpoints.
Meanwhile, my co-worker was trying to approach things differently. He went into Ranorex Studio and defined an endpoint, calling it "Chrome". Here's what he did in code:
'We found that if you didn't kill localhost, it would not let you see the endpoints created in Studio
Host.Local.KillBrowser("localhost")
Host.MakeCurrentHost("Chrome")
Host.Current.OpenBrowser("www.ranorex.com", "chrome")
'So this also launches chrome on our other server (defined in the endpoint created via Studio) but now how do you use Ranorex to find the browser object???
'This cannot find the Chrome form. Also tried Host.Local. Didn't work either
Dim MyForm As Ranorex.Form = Nothing
If Not Host.Current.TryFindSingle(".//form[@ProcessName='chrome']", 30000, MyForm) Then
Console.WriteLine("Oops. Can't find form.")
End If
So then I thought, why not combine the 2. That is, use the code in the first part to create the endpoint dynamically in the code, and then attach to it... but that didn't work. It cannot see the dynamic endpoint...
'First kill local browsers
Host.Local.KillBrowser("localhost")
'Use code from first example to create an endpoint
Dim sEPURL As String = "http://vmtaclt17-a99:4444/wd/hub"
Dim fac As New Ranorex.Core.RemoteEndpointFactory
Dim ep = fac.CreateTransientWebDriverEndpoint(New WebDriverEndpointInfo("TempEP", sEPURL))
Dim cfg = WebDriverConfiguration.FromJson("{""platform"": ""Windows 8.1"", ""browserName"": ""chrome"", ""version"": ""59.0""}")
cfg.Name = "MyConfig1"
cfg.Description = "Code sample Config"
ep.ActivateConfiguration(cfg)
ep.ConnectAsync().ContinueWith(Sub(antecendent) ep.MakeCurrentHostAsync()).Wait()
'Now use code from second example to connect to dynamic endpoint
Host.MakeCurrentHost("TempEP") '<== Fails here, no endpoint of such name exists.
Host.Current.OpenBrowser("www.ranorex.com", "chrome")
So, any thoughts?
Aracknid