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

selectOption speed with large select boxes #3003

Closed
dzoeteman opened this Issue Apr 19, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@dzoeteman
Contributor

dzoeteman commented Apr 19, 2016

The selectOption speed is particularly slow when there are large select boxes. I propose changing the order of the selectOption function to first search by value, instead of by visible text.
If changing the order is not a good solution, maybe a third argument or a different function to select by value specifically would be nice to add.

To give an idea on timing, I have a select box with 2700 options. If I run my test with the selectOption normally, it takes about 2.8 minutes. If I manually change the Codeception code not to execute the selectByVisibleText() webdriver function, it takes only 25 seconds.

@dzoeteman

This comment has been minimized.

Show comment
Hide comment
@dzoeteman

dzoeteman Apr 19, 2016

Contributor

@DavertMik Let me know which solution is preferred, I can get a PR in.

Contributor

dzoeteman commented Apr 19, 2016

@DavertMik Let me know which solution is preferred, I can get a PR in.

@DavertMik

This comment has been minimized.

Show comment
Hide comment
@DavertMik

DavertMik Apr 19, 2016

Member

It seems to be rare case for most of situation but yes, this should be optimized somehow for you as well. Changing order is not an option, as it is more natural to search by visible test inside a selectbox. Also what If there are values same as option text by they do not correspond. In this case user will have unexpected behavior.

Also I don't like boolean options in API - they are not verbose enough for scenarios.
What I think of is to use the strict locators concept here.

// you can specify the exact manner of selecting option
$I->selectOption('Age', ['value' => '21']);
$I->selectOption('Age', ['text' => 'Adult']);
// or use standard strict locators to match option elements by CSS/XPath
$I->selectOption('Age', ['css' => '.important']);

And yes, if a regular string passed - behavior should not be changed.
If you could get it implemented in WebDriver I can port it to PhpBrowser and Frameworks as well

Member

DavertMik commented Apr 19, 2016

It seems to be rare case for most of situation but yes, this should be optimized somehow for you as well. Changing order is not an option, as it is more natural to search by visible test inside a selectbox. Also what If there are values same as option text by they do not correspond. In this case user will have unexpected behavior.

Also I don't like boolean options in API - they are not verbose enough for scenarios.
What I think of is to use the strict locators concept here.

// you can specify the exact manner of selecting option
$I->selectOption('Age', ['value' => '21']);
$I->selectOption('Age', ['text' => 'Adult']);
// or use standard strict locators to match option elements by CSS/XPath
$I->selectOption('Age', ['css' => '.important']);

And yes, if a regular string passed - behavior should not be changed.
If you could get it implemented in WebDriver I can port it to PhpBrowser and Frameworks as well

@dzoeteman

This comment has been minimized.

Show comment
Hide comment
@dzoeteman

dzoeteman Apr 19, 2016

Contributor

Agreed, that looks like a better option. I hadn't considered it to be indeed more natural in an acceptance test to first search by text.
I'll give it a go and put a PR in.

Contributor

dzoeteman commented Apr 19, 2016

Agreed, that looks like a better option. I hadn't considered it to be indeed more natural in an acceptance test to first search by text.
I'll give it a go and put a PR in.

@javigomez

This comment has been minimized.

Show comment
Hide comment
@javigomez

javigomez Apr 21, 2016

Contributor

@DavertMik you mentioned this strict locator:

['text' => ...

But I haven't found this one in the webdriverBy: https://github.com/facebook/php-webdriver/blob/community/lib/WebDriverBy.php#L18-L21

It does exist?

Were can I found documentation about the Strict locators? I think we are missing a Guide about locators in codeception.com, all what I found are in this blog post http://codeception.com/05-01-2014/codeception-2.0-rc-strict-locators.html#.Vxi09JN97ow and a small reference at http://codeception.com/docs/03-AcceptanceTests#click

If you think we can add info about locating elements into a Guide, I'm happy to help with it. Just point me to the place where you think is better and I can prepare a draft.

Contributor

javigomez commented Apr 21, 2016

@DavertMik you mentioned this strict locator:

['text' => ...

But I haven't found this one in the webdriverBy: https://github.com/facebook/php-webdriver/blob/community/lib/WebDriverBy.php#L18-L21

It does exist?

Were can I found documentation about the Strict locators? I think we are missing a Guide about locators in codeception.com, all what I found are in this blog post http://codeception.com/05-01-2014/codeception-2.0-rc-strict-locators.html#.Vxi09JN97ow and a small reference at http://codeception.com/docs/03-AcceptanceTests#click

If you think we can add info about locating elements into a Guide, I'm happy to help with it. Just point me to the place where you think is better and I can prepare a draft.

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