-
-
Notifications
You must be signed in to change notification settings - Fork 647
Selenium Question(s) #367
Comments
@kevinquillen - Yes, you can get it working inside Drupal VM with the ability to do screenshots through the phantomjs driver... but I usually recommend people either set up CI with that level of detail/automation on a separate server (e.g. Jenkins) or on their host machine, since it will use an actual browser instance, like FireFox. Drupal VM is much better imo for building the tests with a headless browser, though you can get it working either way (if you want screenshots). I'll leave this ticket open in case anyone else wants to chime in with particular tips/tricks. |
I'll try again. I ran a selenium server on my host machine, told Behat that the selenium2 wd_host was 127.0.0.1:4444/wd/host. It just seemed to hang there. Otherwise, everything else works great, I just want to be able to watch it execute in the browser on occasion. |
Here is an error I get when using @javascript to run scenarios, on the remote machine:
behat.yml:
The default api driver works fine. |
This is odd... So, going off of that, I added this to drupalvm config.yml for firewall allowed ports:
I also changed the selenium version to 2.48.2, which seems to be the latest stable release. Re provisioned, and now it works. I can run scenarios with selenium, or mix and match with the default driver or selenium. This was necessary for what I was testing with BigPipe and all caching enabled in D8. |
Ah, I should've thought of that. The default set of allowed ports blocks the ports used for Selenium, so that makes sense. Let's add that to the docs (and/or open up that port in the default example config). |
So, back to the original issue now that that works... I added a new profile in my behat.yml:
I run this command in terminal, on my machine:
I also started a selenium server on the host. What I expect to happen is that Behat connects to the local selenium, opens a browser and I can watch it run through the scenarios. Instead, this error pops up:
The settings.php file has the right MYSQL connection, so I am not sure where it is failing at the moment. No activity occurs in the terminal window running selenium either. |
Just adding on to notes here... here is how you can submit parameters to your context(s):
DesktopContext:
This sets the browser at the assigned dimension (otherwise, Selenium seems to start the browser in a small mobile resolution), and takes a screenshot on a failed scenario for review. The reports directory is created at the root (per the parameter in behat.yml) and any necessary folders underneath are created recursively. Just an example, my implementation saves screenshots in FeatureName/ScenarioName directory so its clear what we are looking at. I suppose this is good enough and we don't necessarily need to see it happening in real time, now that I figured out how to screenshot. Something seems funky with running it locally and executing on the VM anyway. A good next step would be implementing different drivers, so you could use say, Chrome, other than Firefox. This can allow for creating different contexts, like TableContext or MobileContext, with specific dimensions. It was a little hard to discern this from the docs (Behat v3 is not the default navigation), but there is a lot of flexibility in regards to testing in this manner. I should also note that I am using the Drupal Extension - which provides a lot of steps for you OOTB. |
While this works in DrupalVM, if you really want to see BDD tests run in real time or use Chrome over Firefox, you will want to run this alongside DrupalVM: https://github.com/SeleniumHQ/docker-selenium Fire up the hub, then one of the browser images (the Debug containers have a VNC viewer) open the VNC viewer and voila. It is just easier to do that way than try to install additional dependencies into the VM when Docker can be dedicated for that (and just throw away when done). |
I restarted my VM, now I get this when running within the server:
Neither 4444/7055 seem to be listed as ports with netstat -tulpn, even though they are listed as allowed in the config.yml. How can I open them up? nc -l 4444 and 7055 seems to be ineffective. |
@kevinquillen - Did you run |
I did update the base box today. Let me provision again. |
Booya. Provisioning fixed it. Was this because I updated the base box, or I halt/up without provisioning? |
Not entirely sure... when you provisioned, which tasked showed a |
Updated box this week and running into this issue again... previous fixes are no longer working. Get the old |
Another new error:
I am going to destroy and provision again. The ports are open, but something is not clicking. |
Looks like the solution is to destroy the Vagrant instance, remove the entries from known_hosts (using auto_network plugin can cause some weird issues around ssh keys), add the 7055 port in config.yml, ssh in and open port 7055 in the VM, and then vagrant provision. I think I will try and offload my workflow for this to the dedicated docker from Selenium, unless I am doing something wrong here. |
Regarding the Firefox error... see: SeleniumHQ/selenium#2110 |
For this and #421 , I've decided to add links to the issues in the docs for Behat, and leave it at that... I've found that many projects set up Selenium, PhantomJS, Node, Behat, and the Drupal plugins slightly differently, and there's no way I want to try to account for all the flavors in Drupal VM's docs. Rather, as long as the base components are able to work, I point to resources like the official docs, implementations like BLT, and issues like these, and I leave it up to the reader to decide how to implement automated tests into their own projects. |
I'm struggling here with this a little bit. I've followed all the suggestions in the two issues linked from the docs but I'm getting a similar error when using @javascript:
I've opened up port 7055 as suggested above and also installed the earlier version of selenium server. No joy. Could anyone suggest anything else? iptables -L shows
May have to look at the docker route but I'm pretty new to Docker. Cheers |
I followed the docs on installing Selenium for DrupalVM, my config.yml for Behat looks correct. Upon executing (from PHPStorm, which is executing it remotely), it times out after 60 seconds and says it could not connect to port 7055 (not sure where it is getting that from). The config.yml is set to 4444.
If I were to get it running, is there a way to make it take screenshots on error?
I want a way where I can run Behat (which I can do with the goutte driver, without using Selenium) - but have the option to view what is happening from the browser so I can investigate when a test fails.
It's been a very long time since I have ran Selenium interactively, and want to get the option to do that again. With Behat it is possible to setup multiple profiles now, granting much more flexibility, and I have found that the best way to test AJAX functionality is with Selenium while watching it actually do it in a browser.
The text was updated successfully, but these errors were encountered: