Hi everyone, I believe that my expectations are high, so I'm not even sure it can wor. I found some older links where it said it is not possible, but I feel like I'm close to the solution and since those answers (2011) it may have changed:
My configuration:
- Selenium version: 3.8
- I have up to dated drivers (just downloaded them)
- I tried with Chrome and Firefox
- Testing on Windows 10 Pro
What I want:
1.
I start browser in my app (basically Chrome, but after many unsuccessful tries I also tried it with Firefox):
new ChromeDriver(options)
in case of Firefox:
new FirefoxDriver(options)
2.
After it starts I get the port where it runs and SessionId, I write them to file.
3.
In my tests, I would like to connect to this browser and use it.
var uri = new Uri("http://localhost:" + portItRuns); // if I concat "/wd/hub" or "/hub" it still doesn't work.
var webDriver = new RemoteWebDriver(uri, options) // or new RemoteWebDriver(uri, DesiredCapabilities.Chrome())
What happens:
1.
Browser = Chrome, Uri = http://localhost:port
Starts a new browser with the previously created driver.
2.
Browser = Chrome, Uri = http://localhost:port/hub or Uri = http://localhost:port/wd/hub
OpenQA.Selenium.WebDriverException: Unexpected error. unknown command: hub/session
3.
Browser = Firefox, Uri = http://localhost:port
OpenQA.Selenium.WebDriverException: Session is already started
4.
Browser = Firefox, Uri = http://localhost:port/wd/hub or http://localhost:port/hub
System.InvalidOperationException: POST /wd/hub/session did not match a known command
What I have also tried:
Override the SessionId: in the Execute method like it writes in the article (link below)
With this, I could create a browser and then attach to to it. But the browser was created in the Test project, and it was a CustomRemoteWebDriver.
If I change the SessionId to the one I passed from the program, instead of the one in this article, it doesn't work:
No exception occurs, the test continues, but if I debug my test, put a breakpoint to after my CustomRemoteWebDriver was instantiated, checking its properties, it says: InvalidOperandExceptions as the values.
My navigation events also doesn't make any effect, but the test continues
What I'm looking for:
After this long struggling I would like a solution how I could attach to my running browser. Is it even possible with Selenium? Any other solution - without Selenium (the driver is running, so it may be remotable)?