minkphp / minkselenium2driver Goto Github PK
View Code? Open in Web Editor NEWSelenium2 (webdriver) driver for Mink framework
License: MIT License
Selenium2 (webdriver) driver for Mink framework
License: MIT License
Current "key*" methods are just emulating JS events instead of actually pressing corresponding keys. I recommend using dedicated WebDriver calls for that instead.
Though we need to add test to Mink to ensure that fired JS events are still fired as they should.
Why is my GitHub username and password required during Composer Update?
behat/mink-selenium2-driver
No other repo requires this.
What's up with this behaviour?
These tests should be debugged to figure whether we can improve the PhantomJS support: https://travis-ci.org/Behat/MinkSelenium2Driver/jobs/24086908
I could not get my test to work when using the dragTo implementation in the Selenium2Driver, but this worked:
private function performDragAndDrop(Element $element, Element $dropZone)
{
$session = $this->session->getDriver()->getWebDriverSession();
//this requires a sequence of steps as follows:
//1st find the source and target/destination elements to use as reference to do the drag and drop
$from = $session->element('xpath',$element->getXpath());
$to = $session->element('xpath',$dropZone->getXpath());
//now perform drag and drop
$session->moveto(array('element' => $from->getID())); //move to source location, using reference to source element
$session->buttondown(""); //click mouse to start drag, defaults to left mouse button
$session->moveto(array('element' => $to->getID())); //move to target location, using reference to target element
$session->buttonup(""); //release mouse to complete drag and drop operation
//it may be worthwhile to encapsulate these steps into a function called draganddrop($src,$target), etc.
}
Most of the code is just a cut and paste from an example I found in a comment on the internet(I cannot remember where), but it is fairly straight forward.
"Usage Example" on github repo page is wrong and confusing.
it defines $startUrl and never use it, instead it use $url.
also proper working example would be much appreciated.
i mean example .feature file together with FeatureContext class.
it doesn't have to test anything, just load selenium2driver and not fail when ./bin/behat is executed, that would be more than enough.
I just testing autocomplete form with behat and mink (selenium2 driver). My autocomplete field is triggering by keyUp event. I see that driver send keys, trigger change event, but not triggering keyUp or keyDown. So if you try to change (https://github.com/Behat/MinkSelenium2Driver/blob/master/src/Behat/Mink/Driver/Selenium2Driver.php#L626)
$script = "Syn.trigger('change', {}, {{ELEMENT}})";
with
$script = "Syn.trigger('change', {}, {{ELEMENT}});Syn.trigger('keyup', {}, {{ELEMENT}})";
, then all will work.
In selectOption
method a value that should be selected is escaped manually (see https://github.com/Behat/MinkSelenium2Driver/blob/master/src/Behat/Mink/Driver/Selenium2Driver.php#L663)
$valueEscaped = str_replace('"', '\"', $value);
rather, than using json_ecode
:
$valueEscaped = json_encode("$value");
By using json_encode
the need of using double quotes later in JavaScript is also eliminated.
Experienced through saucelabs, but when running this against safari + iOs, Key::BACKSPACE . Key::DELETE
end up being inserted as characters.
After updating my project's dependencies using Composer, the sample web feature on the Behat site no longer works.
http://docs.behat.org/cookbook/behat_and_mink.html#test-in-browser-selenium2-session
After a few tests, I've traced it back to this specific update.
Haven't looked into the actual code, I'm brand new to Behat.
UPDATE: I just realized that the package that broke is actually a dependence, the instaclick/php-webdriver package. Version 1.0.8 is fine, 1.0.10 is not.
Thanks.
Hello,
I've already run...
composer.phar require behat/symfony2-extension:* behat/mink-browserkit-driver:*
And I want to add selenium driver support...
composer.phar require behat/mink-selenium2-driver:*
composer.phar require instaclick/php-webdriver:* behat/mink-selenium2-driver:*
composer.phar require instaclick/php-webdriver:@dev behat/mink-selenium2-driver:*
JSonWiredProtocol provide special command for handling full page html. Here it is: http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/source
So method getHtml should be in case of //html xpath
public function getHtml($xpath){
return $this->wdSession->source();
}
Right now driver is skipping testMouseEvents
and implementing checkings for mouse events in testOtherMouseEvents
test. Such approach is no longer valid since recently we've separated testMouseEvents
test into per-event tests.
Need to update override to individually skip tests with non-supported events.
Is it possible to keep the browser window open between test sessions, and then keep using it for the next test, in order to speed things up?
When running a test using Safari, Selenium2Driver::getTagName()
will return the tag in uppercase. This causes a problem down the line because conditionals check for the lowercase version of the tag name. For example, NodeElement::selectOption()
:
if ('select' !== $this->getTagName()) {
$this->getSession()->getDriver()->selectOption($this->getXpath(), $option, $multiple);
return;
}
This means that a test which works one way in Firefox will not work the same way in Safari. In the selectOption case, it means that you can't use the label to select an option in Safari, but instead have to use the value attribute, while you can use the label in Firefox.
This could be considered a bug in Selenium, but it seems less likely that it would be fixed there since it could potentially break client code if that client code relies on this distinction.
WebDriver
, that is used supports any custom options to be passed to each curl request
it makes to Selenium.
It makes sense to make access to these options possible (e.g. in driver's constructor) to for example set larger connection timeout for Selenium servers that are far away and respond not so quickly.
I've getting following output from running tests on Safari on Mac:
phpunit
PHPUnit 3.7.28 by Sebastian Bergmann.
The Xdebug extension is not loaded. No code coverage will be generated.
I...FF......EE.....E.........FFFF.EF......F....FFF.F.FFSS
Time: 39.91 seconds, Memory: 7.00Mb
There were 4 errors:
1) Tests\Behat\Mink\Driver\Selenium2DriverTest::testWindow
WebDriver\Exception\NoSuchWindow: No such window: popup_1 (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 10 milliseconds
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:14:00'
System info: host: 'alex-mbp', ip: '192.168.1.6', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9', java.version: '1.6.0_65'
Session ID: null
Driver info: org.openqa.selenium.safari.SafariDriver
Capabilities [{platform=MAC, javascriptEnabled=true, cssSelectorsEnabled=true, secureSsl=true, browserName=safari, takesScreenshot=true, version=7.0}]
.../vendor/instaclick/php-webdriver/lib/WebDriver/Exception.php:157
.../vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php:140
.../vendor/instaclick/php-webdriver/lib/WebDriver/Session.php:266
.../src/Behat/Mink/Driver/Selenium2Driver.php:406
.../vendor/behat/mink/src/Behat/Mink/Session.php:294
.../vendor/behat/mink/tests/Behat/Mink/Driver/JavascriptDriverTest.php:49
2) Tests\Behat\Mink\Driver\Selenium2DriverTest::testGetWindowNames
Undefined offset: 1
.../vendor/behat/mink/tests/Behat/Mink/Driver/JavascriptDriverTest.php:91
3) Tests\Behat\Mink\Driver\Selenium2DriverTest::testDragDrop
WebDriver\Exception\UnknownError: Unknown command: mouseMoveTo (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2 milliseconds
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:14:00'
System info: host: 'alex-mbp', ip: '192.168.1.6', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9', java.version: '1.6.0_65'
Session ID: null
Driver info: org.openqa.selenium.safari.SafariDriver
Capabilities [{platform=MAC, javascriptEnabled=true, cssSelectorsEnabled=true, secureSsl=true, browserName=safari, takesScreenshot=true, version=7.0}]
.../vendor/instaclick/php-webdriver/lib/WebDriver/Exception.php:157
.../vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php:140
.../vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php:200
.../vendor/instaclick/php-webdriver/lib/WebDriver/Container.php:218
.../src/Behat/Mink/Driver/Selenium2Driver.php:932
.../src/Behat/Mink/Driver/Selenium2Driver.php:932
.../vendor/behat/mink/src/Behat/Mink/Element/NodeElement.php:275
.../vendor/behat/mink/tests/Behat/Mink/Driver/JavascriptDriverTest.php:204
4) Tests\Behat\Mink\Driver\Selenium2DriverTest::testPageControlls
WebDriver\Exception\UnknownError: Yikes! Safari history navigation does not work. We can go forward or back, but once we do, we can no longer communicate with the page... (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 9 milliseconds
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:14:00'
System info: host: 'alex-mbp', ip: '192.168.1.6', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9', java.version: '1.6.0_65'
Session ID: null
Driver info: org.openqa.selenium.safari.SafariDriver
Capabilities [{platform=MAC, javascriptEnabled=true, cssSelectorsEnabled=true, secureSsl=true, browserName=safari, takesScreenshot=true, version=7.0}]
.../vendor/instaclick/php-webdriver/lib/WebDriver/Exception.php:157
.../vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php:140
.../vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php:200
.../vendor/instaclick/php-webdriver/lib/WebDriver/Container.php:218
.../src/Behat/Mink/Driver/Selenium2Driver.php:396
.../src/Behat/Mink/Driver/Selenium2Driver.php:396
.../vendor/behat/mink/src/Behat/Mink/Session.php:276
.../vendor/behat/mink/tests/Behat/Mink/Driver/GeneralDriverTest.php:291
--
There were 12 failures:
1) Tests\Behat\Mink\Driver\Selenium2DriverTest::testPatternGetWindowNames
Failed asserting that 'a8nk7bp6wbbj' matches PCRE pattern "/[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}/".
.../tests/Behat/Mink/Driver/Selenium2DriverTest.php:85
2) Tests\Behat\Mink\Driver\Selenium2DriverTest::testGetWindowName
Failed asserting that 'a8nk7bp6wbbj' matches PCRE pattern "/[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}/".
.../tests/Behat/Mink/Driver/Selenium2DriverTest.php:97
3) Tests\Behat\Mink\Driver\Selenium2DriverTest::testCookie
Failed asserting that 'Previous cookie: client cookie set' contains "Previous cookie: NO".
.../vendor/behat/mink/tests/Behat/Mink/Driver/GeneralDriverTest.php:147
4) Tests\Behat\Mink\Driver\Selenium2DriverTest::testCookieWithPaths with data set #0 ('session_reset')
Failed asserting that 'Previous cookie: client cookie set' contains "Previous cookie: NO".
.../vendor/behat/mink/tests/Behat/Mink/Driver/GeneralDriverTest.php:166
5) Tests\Behat\Mink\Driver\Selenium2DriverTest::testCookieWithPaths with data set #1 ('cookie_delete')
Failed asserting that 'Previous cookie: client cookie set' contains "Previous cookie: NO".
.../vendor/behat/mink/tests/Behat/Mink/Driver/GeneralDriverTest.php:166
6) Tests\Behat\Mink\Driver\Selenium2DriverTest::testReset
Failed asserting that 'Previous cookie: srv_var_is_set' contains "Previous cookie: NO".
.../vendor/behat/mink/tests/Behat/Mink/Driver/GeneralDriverTest.php:206
7) Tests\Behat\Mink\Driver\Selenium2DriverTest::testElementsTraversing
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'h1'
+'H1'
.../vendor/behat/mink/tests/Behat/Mink/Driver/GeneralDriverTest.php:306
8) Tests\Behat\Mink\Driver\Selenium2DriverTest::testLinks
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'http://localhost/vendor/behat/mink/tests/Behat/Mink/Driver/web-fixtures/redirect_destination.php'
+'http://localhost/vendor/behat/mink/tests/Behat/Mink/Driver/web-fixtures/links.php'
.../vendor/behat/mink/tests/Behat/Mink/Driver/GeneralDriverTest.php:438
9) Tests\Behat\Mink\Driver\Selenium2DriverTest::testMultiselect
Failed asserting that '10' matches expected '30'.
.../vendor/behat/mink/tests/Behat/Mink/Driver/GeneralDriverTest.php:561
10) Tests\Behat\Mink\Driver\Selenium2DriverTest::testElementSelectedStateCheck with data set #0 ('select_number', '30', 'thirty')
Failed asserting that false is true.
.../vendor/behat/mink/tests/Behat/Mink/Driver/GeneralDriverTest.php:602
11) Tests\Behat\Mink\Driver\Selenium2DriverTest::testElementSelectedStateCheck with data set #1 ('select_multiple_numbers[]', '2', 'two')
Failed asserting that false is true.
.../vendor/behat/mink/tests/Behat/Mink/Driver/GeneralDriverTest.php:602
12) Tests\Behat\Mink\Driver\Selenium2DriverTest::testMultiInput
Failed asserting that '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru"><head>
<title>Multi input Test</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
</head>
<body>
<h1>Multi input Test</h1>
<form method="POST" action="advanced_form_post.php">
<label>
First
<input type="text" name="tags[]" value="tag1">
</label>
<label>
Second
<input type="text" name="tags[]" value="tag2">
</label>
<label>
Third
<input type="text" name="tags[]" value="tag1">
</label>
<input type="submit" name="submit" value="Register">
</form>
</body></html>' contains " 'tags' =
array (
0 = 'tag2',
1 = 'one',
2 = 'tag3',
),".
.../vendor/behat/mink/tests/Behat/Mink/Driver/GeneralDriverTest.php:785
FAILURES!
Tests: 57, Assertions: 157, Failures: 12, Errors: 4, Incomplete: 1, Skipped: 2.
In the setValue
method we're only considering input HTML tags that have type="text"
attribute as valid inputs. This is wrong, because the default type
attribute value is text
.
I can do this in code:
$driver->getWebDriverSession()->timeouts()->implicit_wait(array('ms' => 10000))
I have to wait until after Session has started to set this. It would be better to be able to specify this at construction (or shortly afterwards), and have this call made after the session is started.
Ultimately it would be ideal to be able to plug this through from behat.yml
via the MinkExtension.
Only useful information I can provide is tcpdump details of request/response:
REQUEST:
{"desiredCapabilities":{"platform":"XP","browserName":"internet explorer"}}
RESPONSE:
{"sessionId":"1343340328236","status":0,"value":{"platform":"WINDOWS","cssSelectorsEnabled":true,"javascriptEnabled":true,"browserName":"internet explorer","handlesAlerts":true,"nativeEvents":true,"webdriver.remote.sessionid":"1343340328236","takesScreenshot":true,"version":"9"},"class":"org.openqa.selenium.remote.Response","hCode":29771909}
Platform seems to be ignored.
REQUEST:
{"desiredCapabilities":{"platform":"XP","version":7,"browserName":"internet explorer"}
RESPONSE:
{"status":13,"value":{"message":"Error forwarding the new session cannot find : {platform=XP, browserName=internet explorer, version=7}","class":"org.openqa.grid.common.exception.GridException","stackTrace":[{"fileName":"RequestHandler.java","lineNumber":111,"className":"org.openqa.grid.web.servlet.handler.RequestHandler","methodName":"process"},{"fileName":"DriverServlet.java","lineNumber":84,"className":"org.openqa.grid.web.servlet.DriverServlet","methodName":"process"},{"fileName":"DriverServlet.java","lineNumber":68,"className":"org.openqa.grid.web.servlet.DriverServlet","methodName":"doPost"},{"fileName":"HttpServlet.java","lineNumber":727,"className":"javax.servlet.http.HttpServlet","methodName":"service"},{"fileName":"HttpServlet.java","lineNumber":820,"className":"javax.servlet.http.HttpServlet","methodName":"service"},{"fileName":"ServletHolder.java","lineNumber":565,"className":"org.seleniumhq.jetty7.servlet.ServletHolder","methodName":"handle"},{"fileName":"ServletHandler.java","lineNumber":479,"className":"org.seleniumhq.jetty7.servlet.ServletHandler","methodName":"doHandle"},{"fileName":"SessionHandler.java","lineNumber":225,"className":"org.seleniumhq.jetty7.server.session.SessionHandler","methodName":"doHandle"},{"fileName":"ContextHandler.java","lineNumber":1031,"className":"org.seleniumhq.jetty7.server.handler.ContextHandler","methodName":"doHandle"},{"fileName":"ServletHandler.java","lineNumber":406,"className":"org.seleniumhq.jetty7.servlet.ServletHandler","methodName":"doScope"},{"fileName":"SessionHandler.java","lineNumber":186,"className":"org.seleniumhq.jetty7.server.session.SessionHandler","methodName":"doScope"},{"fileName":"ContextHandler.java","lineNumber":965,"className":"org.seleniumhq.jetty7.server.handler.ContextHandler","methodName":"doScope"},{"fileName":"ScopedHandler.java","lineNumber":117,"className":"org.seleniumhq.jetty7.server.handler.ScopedHandler","methodName":"handle"},{"fileName":"HandlerWrapper.java","lineNumber":111,"className":"org.seleniumhq.jetty7.server.handler.HandlerWrapper","methodName":"handle"},{"fileName":"Server.java","lineNumber":349,"className":"org.seleniumhq.jetty7.server.Server","methodName":"handle"},{"fileName":"AbstractHttpConnection.java","lineNumber":452,"className":"org.seleniumhq.jetty7.server.AbstractHttpConnection","methodName":"handleRequest"},{"fileName":"BlockingHttpConnection.java","lineNumber":47,"className":"org.seleniumhq.jetty7.server.BlockingHttpConnection","methodName":"handleRequest"},{"fileName":"AbstractHttpConnection.java","lineNumber":894,"className":"org.seleniumhq.jetty7.server.AbstractHttpConnection","methodName":"content"},{"fileName":"AbstractHttpConnection.java","lineNumber":948,"className":"org.seleniumhq.jetty7.server.AbstractHttpConnection$RequestHandler","methodName":"content"},{"fileName":"HttpParser.java","lineNumber":857,"className":"org.seleniumhq.jetty7.http.HttpParser","methodName":"parseNext"},{"fileName":"HttpParser.java","lineNumber":235,"className":"org.seleniumhq.jetty7.http.HttpParser","methodName":"parseAvailable"},{"fileName":"BlockingHttpConnection.java","lineNumber":66,"className":"org.seleniumhq.jetty7.server.BlockingHttpConnection","methodName":"handle"},{"fileName":"SocketConnector.java","lineNumber":254,"className":"org.seleniumhq.jetty7.server.bio.SocketConnector$ConnectorEndPoint","methodName":"run"},{"fileName":"QueuedThreadPool.java","lineNumber":599,"className":"org.seleniumhq.jetty7.util.thread.QueuedThreadPool","methodName":"runJob"},{"fileName":"QueuedThreadPool.java","lineNumber":534,"className":"org.seleniumhq.jetty7.util.thread.QueuedThreadPool$3","methodName":"run"},{"fileName":"Thread.java","lineNumber":679,"className":"java.lang.Thread","methodName":"run"}]}}
Even though the grid console shows an XP platform that has browserName internet explorer and version 7 running.
Could this be webdriver related, or selenium grid? Not sure how to proceed or where to look for help :-(
Hi! This is not a report. I have a question.
How to change the user agent with Selenium2 Driver?
I have tried the following code, but it is an error.
$this->getSession()->getDriver()->getClient()->setServerParameters( array( 'HTTP_USER_AGENT' => $user_agent ) );
thanks!
Method Selenium2Driver::start
, that starts a session doesn't check, that underlying WebDriver class might in fact throw exception of it's own in case something goes wrong.
In this particular case a hostname, that doesn't actually have running Selenium Grid is specified, then \WebDriver\Exception\CurlExec
exception is thrown from CurlService::execute
method.
Maybe this is by design to pass through exceptions underlying libraries (e.g. WebDriver in this case), I don't know. But I personally expecting Mink driver-related exception, when calling Mink driver method.
For example Selenium2Driver::stop
method properly handles such case. Maybe any other method of this driver, that passes calls through WebDriver should use try
and catch
too in case if Selenium server dies somewhere between executed commands.
I'm trying to pass cookie to browser via Mink Session, using Selenium2Driver:
$mink = new Mink([
'selenium2' => new Session(
new Selenium2Driver('firefox', null, 'http://localhost:4444/wd/hub')
),
]);
$session = $mink->getSession('selenium2');
$session->setCookie('test', 'qwe');
echo $session->getCookie('test'); // qwe
$session->visit('http://mydomain-which-dumps-cookies.com'); // no cookie here
echo $session->getCookie('test'); // null
$session->getPage();
die('ok');
Cookie would be passed on http://mydomain-which-dumps-cookies.com
with visit()
method call.
No cookie on http://mydomain-which-dumps-cookies.com
. $_COOKIE
array is empty.
Recently in #96 @stof updated tests to be able to run them on PhantomJS as well.
I think, that following lines from .travis.yml
:
- sh -e /etc/init.d/xvfb start
- export DISPLAY=:99.0
- sleep 4
should be moved to bin/run-selenium.sh
file, since PhantomJS doesn't need frame buffer, because it's headless.
Main issue: minkphp/Mink#406
Originally posted on Behat/Mink
Maybe this is a very hackish way of doing things, but I'd like the ability to find the closest element to my current one. As there's no server-side method for this, I was attempting to write my own by finding the jquery object by it's xpath, using jQuery.closest()
in the session, returning the xpath of that object, and using that to turn it into a NodeElement
object by using find()
. Original post:
I am trying to write my own findClosestElement(NodeElement $element, $type)
method. The aim: perform a jQuery .closest()
call and return the result.
I presumed I would just be able to do the following:
$this->session->evaluateScript(sprintf("return $($x(%s))"), $element->getXpath());
However, this is throwing back:
Runtime.evaluate threw exception: SyntaxError: Unexpected identifier
The contents of $element->getXpath()
is:
((//html//*[@id="body"]/section/section/div[2]/table/tbody/tr[not(contains(@Class, "subtable"))])[5]/descendant-or-self::a)[1]
I believe the problem lies in the quotes not being escaped properly, possibly the quotes around body
and subtable
, but I may be wrong. Running the following directly in chrome console returns the element fine:
$($x('((//html//*[@id="body"]/section/section/div[2]/table/tbody/tr[not(contains(@class, "subtable"))])[5]/descendant-or-self::a)[1]'))
Why am I getting the above error and what can I do about it? I have tried just sending the whole thing through as a string and returning that to make sure evaluateScript()
is running fine, and it does work fine. So it's something to do with the xpath (which I thought would be properly escaped).
Here's what I'm using to return just the string of the xpath I am sending through:
$this->session->evaluateScript(sprintf('return \'%s\'', $element->getXpath()));
This gives me the following returned from the session:
string(126) "((//html//*[@id="body"]/section/section/div[2]/table/tbody/tr[not(contains(@class, "subtable"))])[5]/descendant-or-self::a)[1]"
Finally, I have tried this:
$string = sprintf("$(\$x('%s'));", $element->getXpath());
$closestXpath = $this->session->evaluateScript(sprintf('return %s', $string));
This only throws:
unknown error: $x is not defined
^ Which is available in chrome / firefox etc (I'm using chrome) and works fine in my browser.
The selectOption
method of the driver is only designed to work with SELECT
and INPUT TYPE='RADIO'
elements. However after recent changes a confusing check was added on front of it:
if ('select' !== $tagName && !('input' === $tagName && in_array($this->getAttribute($xpath, 'type'), array('checkbox', 'radio')))) {
throw new DriverException(sprintf('Impossible to select an option on the element with XPath "%s" as it is not a select or radio input', $xpath));
}
suggesting that it also accepts a checkboxes.
@stof , since you made that change I recommend you removing check checkbox
check from here.
There might similar problem with other changed drivers as well.
I have problem (I think that you can help me with that if this is bug in Selenium Driver)
I try to evaluate some javascript variable but Selenium driver returns null on each try.
Example below is from Listener but i have the same results in Context classes.
$result = $event->getContext()
->getSession()
->evaluateScript("(function(){ return '11111'; })()");
I've tried to run closure (like above), and simply return variable
$result = $event->getContext()
->getSession()
->evaluateScript("document.location.href");
One workaround I've found is to write variable contents to some tag / data attribute and pull those data to PHP script from there (getAttribute from NodeElement).
I am working with a legacy codebase and I'm having trouble getting mouseOver()
to trigger a :hover
css event. This code is used all over the place and currently my only workaround is having to run executeScript()
and manually remove the .dropout
and .dropout-trigger
classes. Please help me figure out what I can do to solve this.
I've set up a barebones repository containing a single, basic, HTML file, the CSS I have managed to isolate, and a test.
I have included the vendor/
folder simply so you can get up to speed straight away. I run selenium-server-standalone and phpunit:
java -jar bin/selenium-server-standalone-2.40.0.jar -Dwebdriver.chrome.driver=bin/chromedriver-2.9
bin/phpunit.phar --colors --bootstrap bootstrap.php --filter testMouseOverFail src/
My test is as follows:
public function testMouseOverFail()
{
$driver = new \Behat\Mink\Driver\Selenium2Driver("chrome", array(), "http://localhost:4444/wd/hub");
$session = new \Behat\Mink\Session($driver);
$session->start();
// I placed this all in /var/www/mouseoverfail
$session->visit("http://localhost/mouseoverfail");
$page = $session->getPage();
$services = $page->find('xpath', '//*[@id="nav_services"]');
var_dump("Services visibility: " . $services->isVisible());
$services->mouseOver(); // Nothing is hovered over :(
sleep(5);
$session->stop();
}
Like I said, I'm working with legacy code here and the css is all over the place. It's highly likely that it's our css / html that is the issue and not mink / selenium2driver, but I would just like to find out how I can solve this, as my manual executeScript()
haxx are just terrible.
For some tests, I want to validate that the return keypress behaves correctly.
$field->keyPress(13)
The operation works in Firefox, but fails in every other browser I have tested with (Chrome, IE7, IE8, IE9).
Hi guys,
I found myself liking the ability to use a setHtml()
method (like setValue()
, but alters the innerHTML
JavaScript attribute). Here's what I have done:
setHtml() method - MinkSelenium2Driver
Mink Integration - Mink
Could you let me know if this change looks okay or if you would at all be willing to integrate it via my own PR? :-)
Hey guys!
I noticed that none of the JS drivers (Selenium, Selenium2, Sahi) support basic authentication. Is this inherently not supported by those underlying tools or has it just not been implemented yet inside the drivers?
Thanks!
Current results:
setValue
for input/file: change
fires 2 times (one by Selenium, one manually)setValue
for textarea: change
fires 3 times (one after doing $input->clear()
, one by Selenium, one manually)Tests added in Behat/Mink#495
I believe, that all mouse-related driver actions should involve actual mouse movements.
For example the ->click()
does move the mouse, but the ->doubleclick()
is just emulating the proper JS events but doesn't move the mouse.
This becomes a problem when there is a CSS :hover
class that somehow changes the page behavior.
Current doubleclick
code:
$script = 'Syn.dblclick({{ELEMENT}})';
$this->withSyn()->executeJsOnXpath($xpath, $script);
Proposed doubleclick
code:
$this->wdSession->moveto(array(
'element' => $this->wdSession->element('xpath', $xpath)->getID()
));
$this->wdSession->doubleclick();
Ideal test that be to make hovered element overlap some other element so it won't be visible anymore. Right now we emulate JS events and use JS to test that emulation passed. It's no wonder that we haven't seen such a problem for a long time.
Related issues:
Is setPreference currently supported though behat?
Encountered it trying to deal with a Firefox CSS loading issue while tests are running,
https://groups.google.com/forum/#!topic/selenium-users/QiBgP7SBiyo
I've skimmed over the sources and looking over the docs and I couldn't find the relevant capability to do so.
We have several problems due usage of Syn library for JavaScript event triggering. I propose to switch to WebDriver native event triggering capabilities instead of using Syn library.
During the change we need to carefully check, that when using native WebDriver calls all JavaScript events, that were triggered by Syn library are still triggered by WebDriver itself.
Closes:
We did some rewrite in mouse related tests to be able to individually disable them, when not supported (e.g. focus ones) for a specific drivers. This might have resulted in order change in which tests are being run.
I've tested individually testDoubleClick
and it passed. So I guess the order change of the test was significant after all.
This test should be fixed before releasing the driver
Currently, for text inputs setValue() is emulated by clearing input and typing in new value.
Clearing is done by attaching Key::BACKSPACE keystrokes:
for ($i = 0; $i < strlen($element->attribute('value')); $i++) {
$value = Key::BACKSPACE . $value;
}
But if for some reason the caret gets to the beginning of the input on focus, then the old value will not get cleared and the new value will be prepended to the old value instead.
I think it make sense to add Key::DELETE as well.
Hello ,
I Had tested mink with + selenium2 driver , its very nice , but i missed the get screenshot api
could you please add it
thanks
When using the Selenium browser, I'd like to know that the links are actually clickable by a human. However, if I have a page where the links are not clickable (presumably something is overlayed ontop of it, but maybe because it is off the page), all my link tests still pass.
I haven't gotten in this code deep enough yet to have a solution. But I'm wondering if Selenium2Driver::click() should do something more like doubleClick or rightClick and actually send mouse events to make sure that the items can really be clicked.
Method getAttribute()
returns not null value only if attribute value is not empty string.
So, if we have an element like
<input disabled="">
and we want to know if it's has a disabled attribute we will have a null result (equals like this attribute does not exists).
This is not a correct behavior because it must return an empty string (see http://www.w3.org/TR/html-markup/syntax.html#syntax-attr-empty).
See: http://code.google.com/p/selenium/issues/detail?id=3604
Since the Selenium2Driver already uses Syn.js, I was thinking we could add synthetic events for the drag & drop, and/or update to a newer version of syn.js (from http://github.com/jupiterjs/syn)
The current implementation of setValue()
does not set the focus to a text input field. This is currently a problem with one of our tests, where we are testing autocomplete functionality, which only works with focus on the text field.
I would expect the driver to put focus on the field when entering text, like a real user would do. In previous implementations this was the case.
When using Chrome with this driver, it should be possible to set some more capabilites (specific to chrome browser)...
Here is what my behat.yml
should look like
default:
extensions:
Behat\MinkExtension\Extension:
base_url: http://en.wikipedia.org
goutte: ~
selenium2:
browser: chrome
capabilities:
# browserName: firefox
# version: 8
# platform: ANY
# browserVersion: 8
# browser: firefox
chrome.binary: "/path/to/chrome"
chrome.nativeEvents: true
chrome.switches:
- "--start-maximized"
- "--disable-translate"
# - "--proxy-server=http://localhost:3128"
# - "--another=one"
Too bad this configuration is not allowed (yet)
Cheer
I'm proposing to wrap caught exception details into DriverException
.
For example if WebDriver
throws a Curl exception (or any other exception) with an error details, then when caught by Selenium2Driver code (in stop
method) and hidden behind universal could not close connection
message.
I'm using this driver to test an large angularJS application. A fair amount of our UI behaviour is delivered using CSS as well as javascript...:hover
being an example.
I've been experiencing issues when elements aren't available for clicking because they are not displayed. I presume this is because javascript events are being used (via syn) instead of the native mouse movements available in selenium.
I imagine you've a very good reason for doing this (i've seen https://github.com/Behat/MinkSelenium2Driver/issues/51) relating to compatibility across browsers? Does the selenium server not provide this abstraction very effectively?
Anyhow I've forked and replaced a few commands with native webdriver calls as I don't want our frontend devs to get too wrapped up in the internals of the webdriver api - they're pretty happy with the mink api.
I'll continue to use my fork but I'm wondering if you've plans to adopt more of the native api calls into the mink API?
Hi,
I have step in my context:
/**
* @Then /^I see the name "([^"]*)" of the logged in user$/
*/
public function iSeeTheNameOfTheLoggedInUser($arg1)
{
$this->gui->getSession()->getDriver()->setTimeouts(array('implicit'=>10000));
$this->gui->assertPageContainsText($arg1);
}
in seleniumRC log:
10:24:22.836 INFO - Executing: [implicit wait: 10000] at URL: /session/0d08ff35-0283-4e90-9379-3d94baf71fd5/timeouts)
10:24:22.842 INFO - Done: /session/0d08ff35-0283-4e90-9379-3d94baf71fd5/timeouts
10:24:22.843 INFO - Executing: [find element: By.xpath: //html] at URL: /session/0d08ff35-0283-4e90-9379-3d94baf71fd5/element)
10:24:22.850 INFO - Done: /session/0d08ff35-0283-4e90-9379-3d94baf71fd5/element
but does not affect the setting timeouts.
10s timeout does not apply - does not expect to find an element in next method.
What I doing wrong?
Thanks
When checking a checkbox, javascript events such as onchange and onclick are not executed. Using click instead will successfully trigger the events.
Right now the setValue
method some magic to emulate user input when it's asked just to change input value. For example:
->clear()
WebDriver call before setting new value to it (via ->value()
WebDriver class)I don't know why we're doing all that and not just changing input value to needed one. Besides none of the drivers doing all that.
I propose to remove these manipulations in favor or just plain old ->value
WebDriver call.
Related to #136
Currently, testIssue178
and testIssue215
are relying on upstream fixtures but are implemented here. These tests should be evaluated to check whether they could be moved upstream to run on all drivers
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.