Behat and bad HTML
Some of the sites we are testing have HTML that has multiple ID that are the same. Or elements that do not really have enough info to get a class, name, label or ID out of.
This has been a challenge and there are a few custom steps made to help get through this
Switching to an Iframe with no name or id
This was hard since the default was to target the ID of the frame or name.
Thanks to the help of this thread https://groups.google.com/forum/#!topic/behat/z0z3DscjzhU I was able to pull it off.
Then I the user can choose one of or other custom steps noted below to switch to the frame. The code still needs better error checking e.g. if the element does not exist.
Finding a Submit button on the page when there are 2 with the same name and ID
This snippet allows the user to target a specific element on the page by adding a number. This was done a couple of months ago and at this point I think we have a better way to do it. I will show that below.
Clicking Submit on a form with no button
There are a few ways to do this. So far this one seem to be working best.
Of course if the form does not have an ID we would be in trouble.
Switching to a popup window that has no name
Finally this was the toughest one. We had to use a different branch of Mink to do this. This thread was key to getting this to work https://groups.google.com/forum/#!topic/behat/QNhOuGHKEWI
What we ended up with was basically from that thread
Dealing with Alerts
Dealing with built in browser alerts was found in those threads as well.
I then wrote a helper that I use in other methods to do this.
Since all the steps are called from a web form they user can choose to "Click and Alert" as needed.
Comparing the Size of an element to the Window
Lastly (really this time) we have to check the size of an element to make sure it meets requirements.
This custom steps allows the user to enter a class to get the height of and enter the % it should be of the window.
Noted in comments this might help as well
comments powered by Disqus