Skip to content

Commit f59817b

Browse files
committed
Fix functional tests.
1 parent 0605d38 commit f59817b

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ protected function addSingleCondition($condition, ElementInterface $context)
265265
$this->addCondition($condition['type'], $context);
266266
$createdCondition = $context->find($this->created, Locator::SELECTOR_XPATH);
267267
$this->waitForCondition($createdCondition);
268-
$this->fillCondition($condition['rules'], $createdCondition);
268+
$this->fillCondition($condition['rules'], $createdCondition, $condition['type']);
269269
}
270270

271271
/**
@@ -306,13 +306,14 @@ protected function addCondition($type, ElementInterface $context)
306306
*
307307
* @param array $rules
308308
* @param ElementInterface $element
309+
* @param string|null $type
309310
* @return void
310311
* @throws \Exception
311312
*
312313
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
313314
* @SuppressWarnings(PHPMD.NPathComplexity)
314315
*/
315-
protected function fillCondition(array $rules, ElementInterface $element)
316+
protected function fillCondition(array $rules, ElementInterface $element, $type = null)
316317
{
317318
$this->resetKeyParam();
318319
foreach ($rules as $rule) {
@@ -333,7 +334,7 @@ protected function fillCondition(array $rules, ElementInterface $element)
333334

334335
if ($this->fillGrid($rule, $param)) {
335336
$isSet = true;
336-
} elseif ($this->fillSelect($rule, $param)) {
337+
} elseif ($this->fillSelect($rule, $param, $type)) {
337338
$isSet = true;
338339
} elseif ($this->fillText($rule, $param)) {
339340
$isSet = true;
@@ -390,11 +391,15 @@ protected function fillGrid($rule, ElementInterface $param)
390391
*
391392
* @param string $rule
392393
* @param ElementInterface $param
394+
* @param string|null $type
393395
* @return bool
394396
*/
395-
protected function fillSelect($rule, ElementInterface $param)
397+
protected function fillSelect($rule, ElementInterface $param, $type = null)
396398
{
397-
$value = $param->find('select', Locator::SELECTOR_TAG_NAME, 'select');
399+
//Avoid confusion between regions like: "Baja California" and "California".
400+
$value = $type === 'Shipping State/Province'
401+
? $param->find('select', Locator::SELECTOR_TAG_NAME, 'selectstate')
402+
: $param->find('select', Locator::SELECTOR_TAG_NAME, 'select');
398403
if ($value->isVisible()) {
399404
$value->setValue($rule);
400405
$this->click();
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Mtf\Client\Element;
9+
10+
/**
11+
* @inheritdoc
12+
*/
13+
class SelectstateElement extends SelectElement
14+
{
15+
/**
16+
* @inheritdoc
17+
*/
18+
protected $optionByValue = './/option[normalize-space(.)=%s]';
19+
}

0 commit comments

Comments
 (0)