Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

marking test as skipped if selenium is not running fails test #94

Closed
bountin opened this issue Feb 15, 2012 · 12 comments
Closed

marking test as skipped if selenium is not running fails test #94

bountin opened this issue Feb 15, 2012 · 12 comments

Comments

@bountin
Copy link

bountin commented Feb 15, 2012

If selenium is not running all Selenium tests should be marked as skipped by SeleniumTestCase->skipWithNoServerRunning(). This works but SeleniumTestCase->onNotSuccessfulTest() calls getLocation() of the driver which throws a RuntimeException because curl fails. This exception is not caught properly and fails all selenium tests.

@bountin
Copy link
Author

bountin commented Feb 15, 2012

You can find a pssible workaround at 1ad9105

@briantully
Copy link

I had the same problem when I upgraded from 1.2.1 to 1.2.4.

When the test suite was started all tests were marked as "S" instantaneously.

In my console I saw the following:

INFO - Got result: ERROR Server Exception: sessionId led to start new browser session: Browser not supported:
(Did you forget to add a *?)

Supported browsers include:
*firefox
*mock
*firefoxproxy
*pifirefox
*chrome
*iexploreproxy
*iexplore
*firefox3
*safariproxy
*googlechrome
*konqueror
*firefox2
*safari
*piiexplore
*firefoxchrome
*opera
*iehta
*custom
doesn't exist; perhaps this session was already stopped? on session led to start new browser session: Browser not supported:
(Did you forget to add a *?)

@giorgiosironi
Copy link
Owner

Can you attach a test to replicate the error in 1.2.4? With SeleniumTestCaseTest I get:

$ php run-phpunit.php testOpen Tests/SeleniumTestCaseTest.php
#!/usr/bin/env php
PHPUnit @package_version@ by Sebastian Bergmann.

Configuration read from /home/giorgio/code/phpunit-selenium/phpunit.xml.dist

SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS

@briantully
Copy link

Hey there Giorgio -- thanks for the reply :)

Excuse my ignorance, but I'm not getting any output when I run the command you referred to above.

So I changed directory to the 1.2.4 download package and ran the command:

php run-phpunit.php testOpen Tests/SeleniumTestCaseTest.php 

But there was no output generated.

When I ran the test suite the other day after upgrading to 1.2.4, the results were similar to yours where every test returned a result of "S", which to my understanding means "skipped" and not "success".

@giorgiosironi
Copy link
Owner

I don't think a zip can work as it's missing the git submodules, so PHP is probably swallowing errors due to some setting.
So let me understand: you're running a test with 1.2.4 from PEAR:

  • with or without a Selenium Server running?
  • with a setUp() containing which configuration (it could be the issue)?
    and you get S for all test, which indeed means skipped.

@briantully
Copy link

Thanks again for the response.

Ok, hopefully here's some more useful info. With a combination of PHPUnit 3.6.9 and PHPUnit_Selenium 1.2.4 installed through PEAR I see the following errors when using an xml configuration file to specify host/browser/etc

Current URL: OR Server Exception: sessionId led to start new browser session: Browser not supported:
(Did you forget to add a *?)

Supported browsers include:
*firefox
*mock
*firefoxproxy
*pifirefox
*chrome
*iexploreproxy
*iexplore
*firefox3
*safariproxy
*googlechrome
*konqueror
*firefox2
*safari
*piiexplore
*firefoxchrome
*opera
*iehta
*custom
doesn't exist; perhaps this session was already stopped?

It appears that in versions newer than 1.2.1 the phpunit->selenium->browser->browser attribute as specified in the XML config file doesn't get read any more (or if it does it loses its value).

<phpunit>
  <logging>
    <log type="junit" target="junit.xml" />
  </logging>
  <selenium>
    <browser name="Firefox on localhost"
             browser="*firefox"
             host="localhost"
             port="4444"
             timeout="3000"/>
  </selenium>
  <testsuites>
    <testsuite name="Browser_Tests">
      <file>Tests/PLPTest.php</file>
    </testsuite>
  </testsuites>
</phpunit>

If i update all my tests and add the $this->setBrowser("*firefox") within all of the setUp() functions, then the tests work again. However I prefer to specify browser from the XML config file so that I can use the same tests over for different browsers rather than having to maintain duplicate copies of all tests with just the 1 line browser change.

Any idea why the browser that is defined via the XML config file is respected in version 1.2.1 and not 1.2.4?

@briantully
Copy link

on further inspection, it seems like the phpunit->selenium->browser->host attribute is also being ignored

has something changed in how the XML config file is parsed?

@giorgiosironi
Copy link
Owner

Actually it's the $browsers static property which was broken in 1.2.4, and is now fixed in master. It appears fixing that fixed also the XML configuration: probably PHPUnit is reading the XML configuration and writing it as static properties or something similar.

@giorgiosironi
Copy link
Owner

@briantully
Copy link

awesome! so which version of phpunit-selenium should I revert to -- 1.2.1? Do you have an ETA on when 1.2.5 will be available through PEAR?

Also do you know of an easy way to install an older version of phpunit-selenium?

I've tried pear uninstall phpunit/PHPUnit_Selenium but that doesn't do anything.

i've also tried pear install phpunit/PHPUnit_Selenium-1.2.1 but get the following:

phpunit/PHPUnit_Selenium is already installed and is newer than detected released version 1.2.1
install failed

@hnamd
Copy link

hnamd commented Mar 14, 2012

@briantully
first uninstall your latest version using command :
pear uninstall phpunit/PHPUnit_Selenium-1.2.4

and now install old one:
pear install phpunit/PHPUnit_Selenium-1.2.1

problem will be solved

@briantully
Copy link

thanks, hnamd, but that didn't work for me. I was still stuck at 1.2.4

However,
pear install -f phpunit/PHPUnit_Selenium-1.2.1
seems to have worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants