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

Cannot select option with PhpBrowser #5547

Closed
cosinus90 opened this issue Jun 11, 2019 · 7 comments

Comments

Projects
None yet
2 participants
@cosinus90
Copy link

commented Jun 11, 2019

What are you trying to achieve?

I'd like to select an option of the following html code

 <select id="_payment_type" name="payment_type" required="" class="form-control">
 	<option>За показы</option>
 	<option>За размещение</option>
	<option>qwerty</option>
 </select>

What do you get instead?

[InvalidArgumentException] Input "payment_type" cannot take "" as a value (possible values: За показы, За размещение, qwerty).

Provide console output if related. Use -vvv mode for more details.

Provide test source code if related

			$I->selectOption('#_payment_type', 'qwerty');

Details

  • Codeception version: 3.0.1
  • PHP Version: 7.2
  • Operating System: CentOS 6
  • Installation type: Phar
  • List of installed packages (composer show)
  • Suite configuration:
actor: AcceptanceTester
modules:
    enabled:
        - PhpBrowser:
            url: http://maza.biz/insta
        - \Helper\Acceptance
        - Db:
            dsn: 'mysql:host=localhost;dbname=insta_test'
            user: 'baza'
            password: '9x'
            dump: 'tests/_data/database.sql'
            populate: false  # run populator before all tests
            cleanup: false # run populator before each test
            reconnect: true
            waitlock: 10
    step_decorators:
        - \Codeception\Step\ConditionalAssertion    
@Naktibalda

This comment has been minimized.

Copy link
Member

commented Jun 11, 2019

Why do you think that it is a bug?

@cosinus90

This comment has been minimized.

Copy link
Author

commented Jun 11, 2019

Hm.. I execute

$I->selectOption('#_payment_type', 'qwerty');

qwerty exists in the options but function doesn't select it and prints error message trying to select empty string.
shouldn't the function select the option qwerty?

@Naktibalda

This comment has been minimized.

Copy link
Member

commented Jun 11, 2019

Exception is thrown by https://github.com/symfony/dom-crawler/blob/v4.3.1/Field/ChoiceFormField.php#L140

Probably because matchOption returns false or empty string?

Could you do some debugging and check value of $selValue returned by https://github.com/Codeception/Codeception/blob/3.0.1/src/Codeception/Lib/InnerBrowser.php#L1097 ?

@cosinus90

This comment has been minimized.

Copy link
Author

commented Jun 11, 2019

I use Codeception with phar and it prevents changes

PHP Fatal error: Uncaught PharException: phar "/var/www/x15nicky4/data/www/insta/codecept.phar" SHA1 signature could not be verified: broken signature in /var/www/x15nicky4/data/www/insta/codecept.phar:3
Stack trace:
#0 /var/www/x15nicky4/data/www/insta/codecept.phar(3): Phar::mapPhar()
#1 {main}
thrown in /var/www/x15nicky4/data/www/insta/codecept.phar on line 3

@cosinus90

This comment has been minimized.

Copy link
Author

commented Jun 15, 2019

Ok, I figured out that if I convert this select to key-value one:

<select id="_payment_type" name="payment_type" required="" class="form-control">
	<option value="За показы">За показы</option>
	<option value="За размещение">За размещение</option>
</select>

the method selectOption works fine. But, considering that plain version is a correct HTML mark-up, I guess it should be supported too.
And this
https://github.com/Codeception/Codeception/blob/3.0.1/src/Codeception/Lib/InnerBrowser.php#L1097
returns empty string or false.

Naktibalda added a commit that referenced this issue Jun 16, 2019

@Naktibalda

This comment has been minimized.

Copy link
Member

commented Jun 16, 2019

It looks like this issue was introduced by #2033 4 years ago.
I will make a pull request in a few minutes.

@cosinus90

This comment has been minimized.

Copy link
Author

commented Jun 16, 2019

Oh, it wold be great, I hope the fix will affect

<option>value</option>

case too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.