Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
centreon
centreon-test-lib
Commits
9b956410
Commit
9b956410
authored
Nov 22, 2022
by
Kevin Duret
Browse files
simplify select
parent
dd582e58
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/behat/UtilsContext.php
View file @
9b956410
...
...
@@ -263,32 +263,13 @@ class UtilsContext extends RawMinkContext
/**
* Select an element in list.
*
* @param $css
_i
d The ID of the select.
* @param $css
I
d The ID of the select.
* @param $value The requested value.
* @throws \Exception
*/
public
function
selectInList
(
$css
_i
d
,
$value
)
public
function
selectInList
(
$css
I
d
,
$value
)
{
$found
=
false
;
$elements
=
$this
->
getSession
()
->
getPage
()
->
findAll
(
'css'
,
$css_id
.
' option'
);
foreach
(
$elements
as
$element
)
{
if
(
$element
->
getText
()
==
$value
)
{
$this
->
spin
(
function
(
$context
)
use
(
$element
)
{
$element
->
click
();
return
true
;
},
"Cannot select '
$value
' (
$css_id
)"
,
5
);
$found
=
true
;
break
;
}
}
if
(
!
$found
)
{
throw
new
\
Exception
(
'Could not find value '
.
$value
.
' in selection list '
.
$css_id
.
'.'
);
}
$this
->
assertFind
(
'css'
,
$cssId
)
->
selectOption
(
$value
);
}
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment