Codeception / Codeception/Codeception
Bug with selectOption(): Doesn't select radiobutton by its label
- Lingua principale
- PHP
- Stelle
- 4.9k
- Fork
- 1.3k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
I'm trying to use `selectOption()` with `array('text' => 'Windows')` as its second argument, as shown here:
http://codeception.com/docs/modules/WebDriver#selectOption
Here's a sample HTML:
```html
One
Two
```
And this code is not working:
```php
$I->selectOption('input[name="myfield"]', ['text'=>'Two']);
```
When I try it in an acceptance test, I get:
```bash
[PHPUnit\Framework\Exception] Array to string conversion
```
And when I try it in a functional test, I get:
```bash
[InvalidArgumentException] Input "myfield" cannot take "Two" as a value (possible values: 1, 2).
```
I guess the problem comes from this line in `InnerBrowser.php`: https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/Lib/InnerBrowser.php#L1097
```php
$options = $field->filterXPath(sprintf('//option[text()=normalize-space("%s")]|//input[@type="radio" and @value=normalize-space("%s")]', $option, $option));
```
The second part of the XPath expression searches for inputs with the given **value** (`@value`), not for inputs with the given text as **label**.
* Codeception version: 2.3.5
* PHP Version: 7.1
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.