Skip to content

Remove one second waiting in hidding elements - #20

Merged
RayRom merged 3 commits into
Codeception:masterfrom
Travelport-Czech:patch7
Mar 22, 2017
Merged

Remove one second waiting in hidding elements#20
RayRom merged 3 commits into
Codeception:masterfrom
Travelport-Czech:patch7

Conversation

@buresmi7

Copy link
Copy Markdown
Collaborator

And tests are faster :)

before:
Codeception PHP Testing Framework v2.2.9
Powered by PHPUnit 5.7.15 by Sebastian Bergmann and contributors.

Acceptance Tests (7)
✔</SimpleCept: Check visual changes inside element (9.36s)
✔</NotSameSizeCest: See visual changes after size changes (8.09s)
✔</TimeComparisonCest: See visual changes (8.03s)
✔</TimeComparisonCest: Dont see visual changes (8.21s)
✔</TimeComparisonCest: See visual changes and hide element (8.20s)
✔</TimeComparisonCest: Dont see visual changes and hide element (8.22s)
✔</WriteCurrentImageCest: Write current image file (3.68s)

Time: 55.46 seconds, Memory: 13.75MB

OK (7 tests, 6 assertions)

after:
Codeception PHP Testing Framework v2.2.9
Powered by PHPUnit 5.7.15 by Sebastian Bergmann and contributors.

Acceptance Tests (7)
✔</SimpleCept: Check visual changes inside element (5.07s)
✔</NotSameSizeCest: See visual changes after size changes (4.06s)
✔</TimeComparisonCest: See visual changes (4.01s)
✔</TimeComparisonCest: Dont see visual changes (4.27s)
✔</TimeComparisonCest: See visual changes and hide element (4.57s)
✔</TimeComparisonCest: Dont see visual changes and hide element (4.58s)
✔</WriteCurrentImageCest: Write current image file (1.68s)

Time: 30.17 seconds, Memory: 13.75MB

OK (7 tests, 6 assertions)

@RayRom

RayRom commented Mar 17, 2017

Copy link
Copy Markdown
Collaborator

Not the right decision!!! In case of hiding of blocks, time for redraw of the page is necessary, that is possible do, reduce an interval to 1/4 seconds. You didn't consider productivity of different computers.

@buresmi7

Copy link
Copy Markdown
Collaborator Author

I think that main advantage is:

  1. if there are not any $excludeElements, you do not need wait 1 second
  2. 1 second is too much to wait that are all hiding block redrawed in typical case - for few block to hide - for example I use maximal 5.

$this->webDriverModule->wait(1); says: Ok, for sure I will wait one second, but I don't know when redrawing is done. For few hidding block is it fine, for more, I have no idea how long it takes. In addition I don't know how fast is hardware where I running.

$this->webDriverModule->waitForElementNotVisible($element); says: wait for element is successfully hidden. There is no unsecurity.

So for few blocks it will be much faster. For lot of block it will be safer.

@RayRom

RayRom commented Mar 17, 2017

Copy link
Copy Markdown
Collaborator

LOL! This option is worse than waiting of 1 second after a cycle. It is possible more simply, to expect after a cycle disappearance of the last element from an array.

@buresmi7

Copy link
Copy Markdown
Collaborator Author

You're right, I will fix it. I did not realize, that method executeScript in webdriver is blocking operation

@RayRom

RayRom commented Mar 17, 2017

Copy link
Copy Markdown
Collaborator

I offer such variation:

private function hideElementsForScreenshot(array $excludeElements)
  {
        foreach ($excludeElements as $element) {
            $this->hideElement($element);
        }
        $this->webDriverModule->waitForElementNotVisible(array_pop($excludeElements));
  }

@buresmi7

Copy link
Copy Markdown
Collaborator Author

Thanks, change commited.

@RayRom
RayRom merged commit 5ae0ed2 into Codeception:master Mar 22, 2017
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

Successfully merging this pull request may close these issues.

2 participants