Open gonzalovilaseca opened 10 years ago
I think you should post to the https://github.com/Behat/MinkExtension instead, since it's MinkExtension that invokes Mink on behalf of Behat.
@stof , repo description says it's extension for Behat 2.4, is that correct? If so, then where MinkExtension for Behat 3.x lives?
Done thxs!
Well, the default browser size is not something supported by drivers out there in a general way. And forcing a call to resizeWindow when starting or resetting the driver does not look like a clean implementation IMO.
Looking at the description, I assume you are using Mink inside your Behat suite. In this case, it is very easy to resize at the beginning of scenarios without writing a step explicitly: put the logic in a @BeforeScenario
and @BeforeOutlineExample
hook.
@aik099 the readme talks about Behat 3. The description requires admin access to update it so I was not able to change it. Now I can, but I was not thinking about it anymore when receiving these rights.
I think mentioning any versions in repo description is bad idea, because when releasing new version it's easy to forgot to update it there as well.
@aik099 I changed it to 2.4+, which is true
I'm currently doing it in @BeforeScenario
, but then every time I create a new context file I have to remember to resize the window, it's an extra step that could be avoided with configuration.
The call to resizeWindow should only be done if there is a default size defined, sorry but I don't see why it's not a clean implementation.
@BeforeScenario
does not require putting anything in the feature file
I don't use Behat, but now I totally understand that scenario name set via @BeforeScenario
will prepend it's steps to every executed scenario in suite.
@aik099 @BeforeScenario
is not adding steps. It is about running code before running the steps (there is other hooks before each steps or before the feature, and so on)
Sorry, I meant context file.
Another added step is that I mix both selenium and goutte scenarios in same feature file, so in @BeforeScenario
I also have to check if the browser supports resizing, checking this adds a dependency on Selenium Driver, as if I change the javascript_session configuration parameter I should also have to change the context file.
@gonzalovilaseca well, if we put this in a config file, we would also have to do the same check. And IMO, this does not belong to the core of MinkExtension. Adding it in a hook is very easy (and it the size itself can be configurable through the config file btw) and I don't think it is common enough (most projects don't care about the size at which the browser runs, as it is the first time this feature is requested)
Ok. I guess you will start to see it more often as more responsive projects are built. The problem I found was that in my browser it worked ok, but mink, having a default 800x600 screen hid the texts and displayed icons. Only through a screenshot I was able to find what was going on.
@gonzalovilaseca how did you solved the case when same scenarios were needed to be run on different browser window sizes?
@aik099 Didn't arrive to that point yet, but it doesn't seem easy
@aik099 Didn't arrive to that point yet, but it doesn't seem easy
If you come up with anything or need help, then I'm right here as any other community member.
how did you solved the case when same scenarios were needed to be run on different browser window sizes?
This could be possible when using Behat 3 as you can create several suites using the same scenarios (in this case, we would put the window size as a suite setting, to allow having a different size persuite). In Behat 2, the only thing you can do is use config profiles and launch Behat several times (running all profiles)
default:
suites:
something:
paths: ...
mink_javascript_session: selenium1280
extensions:
BehatTests\MinkExtension:
base_url: 'https://set-from-env-look-at-BehatTests\\MinkExtension'
sessions:
selenium:
selenium2:
browser: chrome
wd_host: "host.docker.internal:4444/wd/hub"
selenium1280:
selenium2:
browser: chrome
wd_host: "host.docker.internal:4444/wd/hub"
capabilities:
chrome:
switches: ["--window-size=1280,900"]
for the newer selenium2driver this does not work anymore - its missing prefs. We need to workaround that part:
in your selenium server you get this error:
from invalid argument: cannot parse capability: goog:chromeOptions
from invalid argument: cannot parse prefs
from invalid argument: must be a dictionary
workaround in behat.yaml
selenium1280:
selenium2:
browser: chrome
wd_host: "host.docker.internal:4444/wd/hub"
capabilities:
chrome:
switches: ["window-size=1280,900"]
prefs:
intl:
(just create anything under prefs, that would require prefs to be an associative array)
It would be great to have a default browser window size that can be defined in configuration, otherwise I have to add an extra step in every Behat scenario of the kind:
'And I set browser window size to "1024" x "768"'