Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Canopy to work with Selenium Hub locally #433

Open
shellwe opened this issue Apr 17, 2018 · 12 comments
Open

Getting Canopy to work with Selenium Hub locally #433

shellwe opened this issue Apr 17, 2018 · 12 comments

Comments

@shellwe
Copy link

shellwe commented Apr 17, 2018

This is not an issue with how Canopy needing to be fixed. It is an issue with me not knowing what I am doing and also not knowing where to post questions about canopy other than here. I apologize for the length, I just want to get more info out there

I upgraded to version 1.5.1 of canopy (the minimum version to get chrome headless to work). For some reason I get errors when upgrading to 1.6 and I don't know enough about F# to debug it.

I have a unit test in F# canopy that works great when I have "start chrome" as well as when I have "start ChromeHeadless", but when I use this code to have it work in selenium hub:

let capability = new DesiredCapabilities()
capability.SetCapability("browser", "chrome")
        
// Setup Remote WebDriver to run on Selenium Hub
let remote = Remote("http://localhost:4444/wd/hub/", capability)

start remote

it kicks off this in my selenium hub command prompt:

12:15:09.159 INFO [RequestHandler.process] - Got a request to create a new session: Capabilities {browser: chrome}

12:15:09.170 INFO [TestSlot.getNewSession] - Trying to create a new session on test slot {server:CONFIG_UUID=97a96575-c281-41e8-a330-acf076e12e95, seleniumProtocol=WebDriver, browserName=chrome, maxInstances=5, platformName=WIN10, platform=WIN10}

and then nothing happens that I can see in the grid.

In case I did something wrong when setting up the grid the two commands I used were:

java -jar selenium-server-standalone.jar -role hub

in one browser and this in another

java -jar selenium-server-standalone.jar -role node -hub http://localhost:4444/grid/register

I can go to the grid console and see the browser icons like I am supposed to, so I assume its set up right.

I get the following error with my unit test in Visual Studio.

Message: Class Initialization method TestName.DetailTests+UnitTest.Setup threw exception. System.InvalidOperationException: System.InvalidOperationException: Unable to create session from org.openqa.selenium.remote.NewSessionPayload@11d55a1
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z'

@lefthandedgoat
Copy link
Owner

Asking questions here is totally fine.

I have never used Selenium Hub before, I can try to set it up and see if I can get it working.

If you are trying to get tests running on multiple machines I can tell you how I have done it in the past if you are interested?

@shellwe
Copy link
Author

shellwe commented Apr 17, 2018

We have a selenium server that we use this other F# canopy project on that works but all it does is just scan a search page and do some various searches.

To get it to work we used phantom JS and used this where we would normally have "start chrome":

let capability = new DesiredCapabilities()
capability.SetCapability("browser", "PhantomJS")
let remote = Remote("http://nameofProdSeleniumServer:4444/wd/hub/", capability)
start remote

I was told to use Chrome Headless so I upgrdaed the project to 1.5.1 and "start ChromeHeadless" works great on my machine, but I try this code on my local selenium hub and it doesn't work.

As a possible alternative to selenium, our build gives us a message saying if upgrade to VS 15 with update 1 the server can do multiple unit tests at once, but we have VS 15 with update 3... so not sure why its giving us that notice and not just doing it.

If by multiple machines you mean multiple instances of chrome headless each running a unit test I am very interested in that. That is the objective we are trying to achieve with Selenium. Right now they run one at a time and take 13 minutes or so total.

@lefthandedgoat
Copy link
Owner

To troubleshoot your chrome problem, make sure that the chromedriver and chrome versions deployed on your selenium service are in sync. You can see what version of chromedriver you need to support your version of chrome here: https://sites.google.com/a/chromium.org/chromedriver/downloads

Each chrome driver version is good for about 3-6 months before needing to update to latest because it just stops working properly.

To run things in parallel there are a few options. I just release canopy 2.x that has native support for writing your tests slightly differently, but running them in parallel (with a unit testing framework that supports it like nunit or expecto)

With 1.x you can run them in parallel by launching your console application multiple times. What build server are you using? Jenkins/TeamCity/TFS?

With Jenkins I setup multiple build agents and setup a build task that was a meta task, that would run sub tasks. You can parameterize your tests and run just a subset of them, and Jenkins will run them in parallel across multiple agents, take the results, and roll them up into the meta build task.

All your agent needs to do is simply get latest on your test code and build it and run the .exe.

Hope this helps. If you run in parallel it will remove the need for your Selenium Hub, you just run the selenium code directly on the build agent. It does require you to periodically update chrome etc on each agent.

@shellwe
Copy link
Author

shellwe commented Apr 17, 2018

To confirm it wasn't a chrome issue I tried to change it to

capability.SetCapability("browser", "ie")
but that didn't work either, it may not be that simple.

I did run into the issue with the chrome driver being out of date and did upgrade the selenium.WebDriver.ChromeDriver was up to date. The only annoyance I get now is sometimes chromediver.exe stays in the processes and when I clean and rebuild I need to go in and manually stop the processes.

We use TFS for our builds.

Also, I was curious to upgrade to Canopy 2.0 to see if that worked and I get the following error when I try to install it from NuGet.

Unable to resolve dependencies. 'System.Drawing.Common 4.0.0' is not compatible with 'canopy 2.0.0 constraint: System.Drawing.Common (>= 4.5.0-preview1-26216-02)

I have have cleared my builds and I even removed System.Drawing.Common from my References and tried again. I am on Framework 4.6.1 and using F# 4.1.0.2, if that helps.

@lefthandedgoat
Copy link
Owner

@shellwe Sorry I have not been able to look into this and will be traveling for the new two weeks. Are you still have this issue?

@shellwe
Copy link
Author

shellwe commented Apr 25, 2018

No worries, we got it to work to some degree, it has a strange issue where it can't find an element and so it fails, then I rerun the test a moment later and it passes. We are working through that now.
As far as the Selenium I think we got that going, my boss did a couple of changes on the selenium server with getting chrome to work. We had to add a capability for running the platform in windows.

Regarding Canopy not being able to upgrade to 2. I have not tried again since I had the issue. I didn't want to risk introducing more problems. Right now we wrap a ranAlready around our canopy runner so it doesn't keep running things over and over while NUnit tries to do its thing.

@av2012
Copy link

av2012 commented Dec 9, 2018

You need to specify browserName instead of browser
let capability = new OpenQA.Selenium.Remote.DesiredCapabilities()
capability.SetCapability("browserName", "firefox")
I also had this issue, but when modified to browserName it started to work.

@manishdube
Copy link

trying to get tests running on multiple machines

@lefthandedgoat are you able to tell us how you achieved this ? i.e. get tests running on multiple machines
Thanks.

@lefthandedgoat
Copy link
Owner

@manishdube I used Jenkins and then had a plugin that would run multiple build definitions at the same time across different agents and merge the results. I would setup builds for testing screen 1, screen 2, screen 3, etc and then they would all kick off and finish when the last one was done and the overall build/run would pass/fail based on the summation of the sub builds.

@manishdube
Copy link

Fascinating. !
How does the merging of results happen.
Is there a sample solution i can look at. Thanks Chris. @lefthandedgoat

@lefthandedgoat
Copy link
Owner

@manishdube Its been five years since I have done it, but I used a plugin I found on Jenkin's website. You defined a job and its purpose was to run other jobs. It handled starting them and merging the overall results, it did not merge the artifacts produced by canopy, just how many tests passed/failed.

@manishdube
Copy link

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants