GithubHelp home page GithubHelp logo

minksahidriver's People

Contributors

ecentinela avatar everzet avatar m0ppers avatar stof avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

minksahidriver's Issues

Multiline xpath expressions are breaking everything

We're recently (see Behat/Mink#438) reformatted xpath expressions in NamedSelector to make them more manageable.

Unfortunately this has broken tests completely, because MinkSahiDriver is putting xpath expressions into JavaScript and this becomes multi-line string and causes JavaScript error.

This is example PHPUnit output:

21) Tests\Behat\Mink\Driver\SahiDriverTest::testAdvancedFormSecondSubmit
Behat\SahiClient\Exception\ConnectionException: error:_sahi.setServerVarPlain('___lastValue___52d82e38d82b9', (function(){
    var count = 0;
    while (_byXPath("(//html/.//input
[./@type = 'submit' or ./@type = 'image' or ./@type = 'button' or ./@type = 'reset'][((./@id = 'Login' or ./@name = 'Login') or contains(./@value, 'Login') or contains(./@title, 'Login'))]
|
.//input
[./@type = 'image'][contains(./@alt, 'Login')]
|
.//button
[((./@id = 'Login' or ./@name = 'Login') or contains(./@value, 'Login') or contains(./@title, 'Login') or contains(normalize-space(string(.)), 'Login'))]
|
.//*
[./@role = 'button'][((./@id = 'Login' or ./@name = 'Login') or contains(./@value, 'Login') or contains(./@title, 'Login') or contains(normalize-space(string(.)), 'Login'))])["+(count+1)+"]")) count++;
    return count;
})())
SyntaxError: unterminated string literal
Sahi.prototype.ex@http://www.domain.tld/_s_/spr/concat.js:3480
@http://www.domain.tld/_s_/spr/concat.js:3267

<a href='/_s_/dyn/Log_getBrowserScript?href=null&n=3482'><b>Click for browser script</b></a>

.../vendor/behat/sahi-client/src/Behat/SahiClient/Connection.php:221
.../vendor/behat/sahi-client/src/Behat/SahiClient/Connection.php:240
.../src/Behat/Mink/Driver/SahiDriver.php:628
.../src/Behat/Mink/Driver/SahiDriver.php:260
.../vendor/behat/mink/src/Behat/Mink/Element/Element.php:91
.../vendor/behat/mink/src/Behat/Mink/Element/Element.php:67
.../vendor/behat/mink/src/Behat/Mink/Element/TraversableElement.php:119
.../vendor/behat/mink/tests/Behat/Mink/Driver/GeneralDriverTest.php:806

Status code reading is not supported by SahiDriver

I get error when called:

$session->getStatusCode();
PHP Fatal error:  Uncaught exception 'Behat\Mink\Exception\UnsupportedDriverActionException' with message 'Status code reading is not supported by Behat\Mink\Driver\SahiDriver' in /behat-mink/vendor/behat/mink-sahi-driver/src/Behat/Mink/Driver/SahiDriver.php:256
Stack trace:
#0 /behat-mink/vendor/behat/mink/src/Behat/Mink/Session.php(192): Behat\Mink\Driver\SahiDriver->getStatusCode()
#1 /behat-mink/mink-example.php(28): Behat\Mink\Session->getStatusCode()

This temporary restriction or a bug? Thanks.

Firefox 13.0.1: inputs are not fill

Hello!
I'm trying to run test on Firefox, but somehow filed are not filled in:

Scenario:

Given I am a guest
And I go to "/app"
And I should see an "input[name=username]" element
And I should see an "input[name=password]" element
And I fill in "username" with "admin"
And I fill in "password" with "password"
And I press "Login"
...

I've tried different pages etc. - still the same result. On Chrome/Opera/Safari this tests goes well and fields go get filled.

Behat hangs when trying to download some files with Sahi driver

A simple scenario that clicks on a link which opens a pdf and then goes to another page, makes behat waits until a time out exception is thrown when using Sahi.

Feature: download a file
  In order to resolve an issue downloading a file with behat
  As a developer
  I need to create a failing test

  Scenario: Try the download of a pdf with Sahi
    Given I am on "http://twig.sensiolabs.org/documentation"
    When I follow "PDF"
    Then I am on "http://www.wikipedia.org"
      Command execution time limit reached: `_sahi._navigateTo("http://www.wikipedia.org", true)`

1 scenario (1 failed)
3 steps (2 passed, 1 failed)
1m7.534s

That doesn't seems to be a problem when using Selenium2

Feature: download a file
  In order to resolve an issue downloading a file with behat
  As a developer
  I need to create a failing test

  Scenario: Try the download of a pdf with Selenium2
    Given I am on "http://twig.sensiolabs.org/documentation"
    When I follow "PDF"
    Then I am on "http://www.wikipedia.org"

1 scenario (1 passed)
3 steps (3 passed)
0m9.935s

I've tried with Firefox and Chrome and the behavior is the same in both.

It's probably related to the type of file to download as the problem si also present here

Feature: download a file
  In order to resolve an issue downloading a file with behat
  As a developer
  I need to create a failing test

  Scenario: Try the download of a file
    Given I am on "http://pear.behat.org/"
    When I follow "2.3.5"
    Then I am on "http://www.wikipedia.org"
      Command execution time limit reached: `_sahi._navigateTo("http://www.wikipedia.org", true)`

1 scenario (1 failed)
3 steps (2 passed, 1 failed)
1m6.76s

but not here

Feature: download a file
  In order to resolve an issue downloading a file with behat
  As a developer
  I need to create a failing test

  Scenario: Try the download of a file
    Given I am on "http://symfony.com/download"
    When I follow "http://symfony.com/download?v=Symfony_Standard_Vendors_2.2.1.tgz"
    Then I am on "http://www.wikipedia.org"

1 scenario (1 passed)
3 steps (3 passed)
0m6.988s

Session interaction timing out for a particular site

I'm experiencing an issue using Mink to control Firefox through Sahi where when I try to interact with the session in any way (e.g. running getPage()->getContent() or simply wait(2000)) I don't get the expected response and Mink eventually times out.

I've used the exact same code for various other websites and it works perfectly. This one single website seems to be stopping either Mink or Sahi from providing a response. I can't seem to find any reliable way of debugging the issue, all I can do is wait for the timeout to occur.

The code I'm using to retrieve the markup from a page is as follows:

// Configure driver
$this->driver = new \Behat\Mink\Driver\SahiDriver('firefox',
    new \Behat\SahiClient\Client(
        new \Behat\SahiClient\Connection(null, CRAWL_SERVER, 9999)
    )
);

// Init session:
$this->session = new \Behat\Mink\Session($this->driver);

// Start session:
$this->session->start();

// Open the url
$this->session->visit($config['url']);

// Get the markup from the page
$markup = $this->session->getPage()->getContent();

The page I'm trying to scrape is: https://www.o2.co.uk/shop/phones/

I also have a post up on on Stack Overflow here.

I'm using Mink 1.6 - installed using composer on 27/11/2014

tl;dr Why is Mink/Sahi timing out on this site?

Failing "testExecuteScript" tests

Following tests are failing:

1) Tests\Behat\Mink\Driver\SahiDriverTest::testExecuteScript with data set #1 ('document.querySelector("h1").textContent = "Hello world";')
Behat\SahiClient\Exception\ConnectionException: error:_call(document.querySelector("h1").textContent = "Hello world";)
SyntaxError: missing ) after argument list
Sahi.prototype.ex@http://www.website.tld/_s_/spr/concat.js:3480
@http://www.website.tld/_s_/spr/concat.js:3267

<a href='/_s_/dyn/Log_getBrowserScript?href=null&n=3480'><b>Click for browser script</b></a>

.../vendor/behat/sahi-client/src/Behat/SahiClient/Connection.php:221
.../vendor/behat/sahi-client/src/Behat/SahiClient/Connection.php:255
.../src/Behat/Mink/Driver/SahiDriver.php:616
.../vendor/behat/mink/src/Behat/Mink/Session.php:300
.../vendor/behat/mink/tests/Behat/Mink/Driver/JavascriptDriverTest.php:324

2) Tests\Behat\Mink\Driver\SahiDriverTest::testExecuteScript with data set #3 ('function () {document.querySelector("h1").textContent = "Hello world";}();')
Behat\SahiClient\Exception\ConnectionException: error:_call(function () {document.querySelector("h1").textContent = "Hello world";}();)
SyntaxError: missing ) after argument list
Sahi.prototype.ex@http://www.website.tld/_s_/spr/concat.js:3480
@http://www.website.tld/_s_/spr/concat.js:3267

<a href='/_s_/dyn/Log_getBrowserScript?href=null&n=3480'><b>Click for browser script</b></a>

.../vendor/behat/sahi-client/src/Behat/SahiClient/Connection.php:221
.../vendor/behat/sahi-client/src/Behat/SahiClient/Connection.php:255
.../src/Behat/Mink/Driver/SahiDriver.php:616
.../vendor/behat/mink/src/Behat/Mink/Session.php:300
.../vendor/behat/mink/tests/Behat/Mink/Driver/JavascriptDriverTest.php:324

3) Tests\Behat\Mink\Driver\SahiDriverTest::testExecuteScript with data set #5 ('(function () {document.querySelector("h1").textContent = "Hello world";})();')
Behat\SahiClient\Exception\ConnectionException: error:_call((function () {document.querySelector("h1").textContent = "Hello world";})();)
SyntaxError: missing ) after argument list
Sahi.prototype.ex@http://www.website.tld/_s_/spr/concat.js:3480
@http://www.website.tld/_s_/spr/concat.js:3267

<a href='/_s_/dyn/Log_getBrowserScript?href=null&n=3480'><b>Click for browser script</b></a>

.../vendor/behat/sahi-client/src/Behat/SahiClient/Connection.php:221
.../vendor/behat/sahi-client/src/Behat/SahiClient/Connection.php:255
.../src/Behat/Mink/Driver/SahiDriver.php:616
.../vendor/behat/mink/src/Behat/Mink/Session.php:300
.../vendor/behat/mink/tests/Behat/Mink/Driver/JavascriptDriverTest.php:324

Consider deprecating this driver

This driver suffers from many cases where it does not behave properly (see failures in the testsuite).

It is also much slower than Selenium2 (see the time spent to run the testsuite), has less features than Selenium2, and is a pain to maintain.
I suggest marking this driver as deprecated (and unmaintained), acknowledging the fact that we haven't managed to fix it since years (the testsuite has never been green since the introduction of the driver testsuite ensuring proper driver behavior). If anyone is using the driver and wants to bring it uptodate, we can still make them a driver maintainer and undeprecate the driver if its testsuite becomes green.

If we do this, we should do a final release of the driver (as we did for SeleniumDriver).

/cc @aik099

Various test failures

I'm having following test suite failures (some were posted in dedicated tasks):

1) Behat\Mink\Tests\Driver\Custom\ExtraTest::testIssue32
xpath with line ending works
Failed asserting that null is not null.

.../tests/Custom/ExtraTest.php:20


7) Behat\Mink\Tests\Driver\Form\Html5Test::testHtml5FormRadioAttribute
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'invalid'
+'f'

.../vendor/behat/mink/driver-testsuite/tests/Form/Html5Test.php:45

8) Behat\Mink\Tests\Driver\Form\RadioTest::testSameNameInMultipleForms
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'test3'
+'test2'

.../vendor/behat/mink/driver-testsuite/tests/Form/RadioTest.php:69

9 Behat\Mink\Tests\Driver\Form\SelectTest::testSetValueSingleSelect
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'10'
+'20'

.../vendor/behat/mink/driver-testsuite/tests/Form/SelectTest.php:92

10) Behat\Mink\Tests\Driver\Form\SelectTest::testSetValueMultiSelect
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
-    0 => '1'
-    1 => '2'
+    0 => '2'
+    1 => '3'
 )

.../vendor/behat/mink/driver-testsuite/tests/Form/SelectTest.php:102

Sahi time limit reached

Hey I'm using Behat with Mink and Sahi. My Web-Application is running local with apache and XAMPP.

I just tryed to get the hole page with

$driver = new \Behat\Mink\Driver\SahiDriver('firefox',
        new \Behat\SahiClient\Client(
            new \Behat\SahiClient\Connection(null, 'localhost', 9999)
)
);
$session = new \Behat\Mink\Session($driver);
$session->start();
$session->visit('https://localhost/CMS/index.php/login/login');
echo $session->getPage()->getContent();

and get this error:
Command execution time limit reached: _sahi.setServerVarPlain('___lastValue___527a9575b8270', document.getElementsByTagName("html")[0].innerHTML)

After I deactivated my https connection on my Side i was able to get the page. I think Sahi don't like the Certificate or something like this.

Hope this will help someone and someone cane give me an advice how I'm able to handle a https connection.

Sahi + Phantom processes dont exit() and keep system VERY busy for a long time

Hi,

I'm using Mink + Sahi + PhantomJS for scraping purposes.

I have a problem in which sahi takes huge amount of memory and cpu even after the scraping task has been completed. Also, phantomJS processes linger for many many minutes until they exit.
This takes lots of system resources and is not really usable for us as a result.

In our application design many CLI php processes start, each is given a URL to surf to, it surfs to that page, process the page html and extract some information, report it, then finish and the PHP process exits.

I hope this is a good place to check this. Any help will be appreciated!

Ensure that "change" event is fired only once per "setValue" call

Current results:

  • setValue for input/file: change fires 0 times
  • setValue for textarea: change fires 0 times

Since selectOption, check and uncheck for Sahi does fire change event without us doing manual firing, then I guess it's some bug in SahiClient side.

Tests added in Behat/Mink#495

Method `selectRadioOption` escapes xpath twice

Method selectRadioOption of the driver is escaping given xpath and then giving it to getAttribute method which does the same.

This bug unnoticed for a long time since it can't be seen when xpath doesn't contain any escapable symbols.

In Behat/Mink#434 we've added extra line endings to make xpaths more readable, which allowed to catch wrong xpath escaping code in this and other drivers.

No exception is thrown, when accessing missing elements

Recently in Mink a tests, that validate that exception is thrown during attempt to act (e.g. click) on an element, that isn't present on a page throw an exception.

It appears though, that some of them aren't passing currently:

2) Behat\Mink\Tests\Driver\Basic\ErrorHandlingTest::testCheckInvalidElement
Failed asserting that exception of type "Behat\Mink\Exception\DriverException" is thrown.

3) Behat\Mink\Tests\Driver\Basic\ErrorHandlingTest::testUncheckInvalidElement
Failed asserting that exception of type "Behat\Mink\Exception\DriverException" is thrown.

4) Behat\Mink\Tests\Driver\Basic\ErrorHandlingTest::testIsVisibleNotFoundElement
Failed asserting that exception of type "Behat\Mink\Exception\DriverException" is thrown.

5) Behat\Mink\Tests\Driver\Basic\ErrorHandlingTest::testFocusFoundElement
Failed asserting that exception of type "Behat\Mink\Exception\DriverException" is thrown.

6) Behat\Mink\Tests\Driver\Basic\ErrorHandlingTest::testBlurFoundElement
Failed asserting that exception of type "Behat\Mink\Exception\DriverException" is thrown.

Slow TestSuite run speed

The test suite is running terribly slow (compared to Selenium2). Maybe we're setting some kind of script running speed and it's stuck in Sahi settings until all tests are done?

While debugging test suite I've noticed that sending 1 command to Sahi (going to /_syn/... url) tooks more then 1 second. It's even worse on Travis. Maybe the problem is really in HTTP connection handling in SahiClient.

Sahi client exception with multiline strings

Originally created at Behat/Behat#142

Given my behat.yml:

default:
    extensions:
      Behat\MinkExtension\Extension:
        base_url: 'http://www.google.com'
        goutte:    ~
        selenium2: ~
        sahi: ~
        javascript_session: sahi

And some lines in my feature context:

<?php
    /**
     * @Given /^I fill in "([^"]*)" with:$/
     */
    public function iFillInWith($field, PyStringNode $value)
    {
        $field = $this->fixStepArgument($field);
        $value = $this->fixStepArgument($value->getRaw());
        $this->getSession()->getPage()->fillField($field, $value);
    }

    /**
     * Returns fixed step argument (with \\" replaced back to ").
     *
     * @param string $argument
     *
     * @return string
     */
    protected function fixStepArgument($argument)
    {
        return str_replace('\\"', '"', $argument);
    }

And my test.feature:

Feature: Test
    Do do do
    Do do do
    Do do do

    @javascript
    Scenario: Test with PyString
        Given I am on "/"

        When I fill in "q" with:
            """
            FOOBAR

            Bill
            """

I run this and get this error in the output:

php ./bin/behat features/test.feature 
Feature: Test
    Do do do
    Do do do
    Do do do

  @javascript
  Scenario: Test with PyString # features/test.feature:7
    Given I am on "/"          # FeatureContext::visit()
    When I fill in "q" with:   # FeatureContext::iFillInWith()
      """
      FOOBAR

      Bill
      """
      error:_setValue(_byXPath("(//html/.//*[self::input | self::textarea | self::select][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'hidden')][(((./@id = 'q' or ./@name = 'q') or ./@id = //label[contains(normalize-space(string(.)), 'q')]/@for) or ./@placeholder = 'q')] | .//label[contains(normalize-space(string(.)), 'q')]//.//*[self::input | self::textarea | self::select][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'hidden')])[1]"), "FOOBAR

      Bill")
      SyntaxError: unterminated string literal
      ()@http://www.google.com/_s_/spr/concat.js:3016
      @http://www.google.com/_s_/spr/concat.js:2822

      <a href='/_s_/dyn/Log_getBrowserScript?href=null&n=3016'><b>Click for browser script</b></a>

1 scenario (1 failed)
2 steps (1 passed, 1 failed)
0m14.31s

If I change the PyString input into this:

Feature: Test
    Do do do
    Do do do
    Do do do

    @javascript
    Scenario: Test with PyString
        Given I am on "/"

        When I fill in "q" with:
            """
            FOOBAR
            """

I get this output:

php ./bin/behat features/test.feature 
Feature: Test
    Do do do
    Do do do
    Do do do

  @javascript
  Scenario: Test with PyString # features/test.feature:7
    Given I am on "/"          # FeatureContext::visit()
    When I fill in "q" with:   # FeatureContext::iFillInWith()
      """
      FOOBAR
      """

1 scenario (1 passed)
2 steps (2 passed)
0m4.049s

So success. Do you know why?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.