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

Friends - MultiSession : Replace close() by quit() in WebDriver and quit all sessions after test #3068

Merged
merged 20 commits into from May 11, 2016

Conversation

Projects
None yet
4 participants
@eXorus
Contributor

eXorus commented May 2, 2016

Hello,

I'm using Selenium Grid with Codeception Friends and Codeception doesn't kill correctly the browser so I'm stuck with a lot of node used for nothing :

public function testFriend1(AcceptanceTester $I)
{
   $I->amOnUrl('http://localhost/toto-nofriend');

   $toto = $I->haveFriend('toto', $I);
   $toto->does(function($I) {
      $I->amOnUrl('http://localhost/toto-friend');
   });
}

with Selenium Hub (2.53) and 2 Firefox nodes
"http://localhost/toto-nofriend" will be on node1
"http://localhost/toto-friend" will be on node2

At the end of the test with close()
node1 will be free slot
node2 will be always used (with state deleted but still used)

At the end of the test with quit()
node1 will be free slot
node2 will be free slot
#3039 #2836

Show outdated Hide outdated src/Codeception/Module/WebDriver.php
@@ -1013,6 +1024,7 @@ public function selectOption($select, $option)
$wdSelect->selectByVisibleText($opt);
$matched = true;
} catch (NoSuchElementException $e) {
// exception treated at the end

This comment has been minimized.

@Nitpick-CI

Nitpick-CI May 2, 2016

Whitespace found at end of line

@Nitpick-CI

Nitpick-CI May 2, 2016

Whitespace found at end of line

Show outdated Hide outdated src/Codeception/Module/WebDriver.php
@@ -1023,6 +1035,7 @@ public function selectOption($select, $option)
$wdSelect->selectByValue($opt);
$matched = true;
} catch (NoSuchElementException $e) {
// exception treated at the end

This comment has been minimized.

@Nitpick-CI

Nitpick-CI May 2, 2016

Whitespace found at end of line

@Nitpick-CI

Nitpick-CI May 2, 2016

Whitespace found at end of line

Show outdated Hide outdated src/Codeception/Module/WebDriver.php
@@ -1038,6 +1051,7 @@ public function selectOption($select, $option)
$optElement->click();
}
} catch (NoSuchElementException $e) {
// exception treated at the end

This comment has been minimized.

@Nitpick-CI

Nitpick-CI May 2, 2016

Whitespace found at end of line

@Nitpick-CI

Nitpick-CI May 2, 2016

Whitespace found at end of line

Show outdated Hide outdated src/Codeception/Module/WebDriver.php
@@ -1090,12 +1104,14 @@ public function unselectOption($select, $option)
$wdSelect->deselectByVisibleText($opt);
$matched = true;
} catch (NoSuchElementException $e) {
// exception treated at the end

This comment has been minimized.

@Nitpick-CI

Nitpick-CI May 2, 2016

Whitespace found at end of line

@Nitpick-CI

Nitpick-CI May 2, 2016

Whitespace found at end of line

Show outdated Hide outdated src/Codeception/Module/WebDriver.php
}
try {
$wdSelect->deselectByValue($opt);
$matched = true;
} catch (NoSuchElementException $e) {
// exception treated at the end

This comment has been minimized.

@Nitpick-CI

Nitpick-CI May 2, 2016

Whitespace found at end of line

@Nitpick-CI

Nitpick-CI May 2, 2016

Whitespace found at end of line

Show outdated Hide outdated src/Codeception/Module/WebDriver.php
@@ -2302,28 +2318,27 @@ public function appendField($field, $value)
$wdSelect->selectByVisibleText($value);
$matched = true;
} catch (NoSuchElementException $e) {
// exception treated at the end

This comment has been minimized.

@Nitpick-CI

Nitpick-CI May 2, 2016

Whitespace found at end of line

@Nitpick-CI

Nitpick-CI May 2, 2016

Whitespace found at end of line

Show outdated Hide outdated src/Codeception/Module/WebDriver.php
}
try {
$wdSelect->selectByValue($value);
$matched = true;
} catch (NoSuchElementException $e) {
// exception treated at the end

This comment has been minimized.

@Nitpick-CI

Nitpick-CI May 2, 2016

Whitespace found at end of line

@Nitpick-CI

Nitpick-CI May 2, 2016

Whitespace found at end of line

@eXorus

This comment has been minimized.

Show comment
Hide comment
@eXorus

eXorus May 2, 2016

Contributor

Fix 11 issues from scrutinizer. I'm done with this PR.

Contributor

eXorus commented May 2, 2016

Fix 11 issues from scrutinizer. I'm done with this PR.

@eXorus

This comment has been minimized.

Show comment
Hide comment
@eXorus

eXorus May 2, 2016

Contributor

I found an issue when test failed (element not visible for example). The PR is not ready yet

Contributor

eXorus commented May 2, 2016

I found an issue when test failed (element not visible for example). The PR is not ready yet

eXorus added some commits May 4, 2016

Show outdated Hide outdated src/Codeception/Module/WebDriver.php
$this->_loadSession($session);
try {
$this->webDriver->quit();
}

This comment has been minimized.

@Nitpick-CI

Nitpick-CI May 4, 2016

Expected 1 space after closing brace; newline found

@Nitpick-CI

Nitpick-CI May 4, 2016

Expected 1 space after closing brace; newline found

Show outdated Hide outdated src/Codeception/Module/WebDriver.php
$key = array_shift(array_keys($this->sessions, $webDriver, true));
try {
$webDriver->quit();
}

This comment has been minimized.

@Nitpick-CI

Nitpick-CI May 4, 2016

Expected 1 space after closing brace; newline found

@Nitpick-CI

Nitpick-CI May 4, 2016

Expected 1 space after closing brace; newline found

eXorus added some commits May 4, 2016

@eXorus

This comment has been minimized.

Show comment
Hide comment
@eXorus

eXorus May 4, 2016

Contributor

I'm done with this PR, it's working well for me on local selenium and selenium grid @DavertMik @Naktibalda

Actually Codeception kill the browsers of the friends at the end of the PHP script (when all objects are destructs).
This PR saved all the sessions opened during a run (friends or not) and kill them at the end of the test case or suite according to the configuration.

Contributor

eXorus commented May 4, 2016

I'm done with this PR, it's working well for me on local selenium and selenium grid @DavertMik @Naktibalda

Actually Codeception kill the browsers of the friends at the end of the PHP script (when all objects are destructs).
This PR saved all the sessions opened during a run (friends or not) and kill them at the end of the test case or suite according to the configuration.

@DavertMik

This comment has been minimized.

Show comment
Hide comment
@DavertMik

DavertMik May 11, 2016

Member

Thank you very much!
This is awesome.

Member

DavertMik commented May 11, 2016

Thank you very much!
This is awesome.

$this->cleanWebDriver();
}
public function cleanWebDriver()

This comment has been minimized.

@DavertMik

DavertMik May 11, 2016

Member

I will make it protected

@DavertMik

DavertMik May 11, 2016

Member

I will make it protected

@DavertMik DavertMik merged commit b6e3a26 into Codeception:2.1 May 11, 2016

3 of 4 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
Scrutinizer 12 updated code elements
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
semaphoreci The build passed on Semaphore.
Details

DavertMik added a commit that referenced this pull request May 11, 2016

DavertMik added a commit that referenced this pull request May 11, 2016

@eXorus eXorus deleted the eXorus:leave-friend branch Jun 7, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment