Skip to content

Commit

Permalink
Fix functional tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmalevanec committed Mar 13, 2019
1 parent 0605d38 commit f59817b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ protected function addSingleCondition($condition, ElementInterface $context)
$this->addCondition($condition['type'], $context);
$createdCondition = $context->find($this->created, Locator::SELECTOR_XPATH);
$this->waitForCondition($createdCondition);
$this->fillCondition($condition['rules'], $createdCondition);
$this->fillCondition($condition['rules'], $createdCondition, $condition['type']);
}

/**
Expand Down Expand Up @@ -306,13 +306,14 @@ protected function addCondition($type, ElementInterface $context)
*
* @param array $rules
* @param ElementInterface $element
* @param string|null $type
* @return void
* @throws \Exception
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function fillCondition(array $rules, ElementInterface $element)
protected function fillCondition(array $rules, ElementInterface $element, $type = null)
{
$this->resetKeyParam();
foreach ($rules as $rule) {
Expand All @@ -333,7 +334,7 @@ protected function fillCondition(array $rules, ElementInterface $element)

if ($this->fillGrid($rule, $param)) {
$isSet = true;
} elseif ($this->fillSelect($rule, $param)) {
} elseif ($this->fillSelect($rule, $param, $type)) {
$isSet = true;
} elseif ($this->fillText($rule, $param)) {
$isSet = true;
Expand Down Expand Up @@ -390,11 +391,15 @@ protected function fillGrid($rule, ElementInterface $param)
*
* @param string $rule
* @param ElementInterface $param
* @param string|null $type
* @return bool
*/
protected function fillSelect($rule, ElementInterface $param)
protected function fillSelect($rule, ElementInterface $param, $type = null)
{
$value = $param->find('select', Locator::SELECTOR_TAG_NAME, 'select');
//Avoid confusion between regions like: "Baja California" and "California".
$value = $type === 'Shipping State/Province'
? $param->find('select', Locator::SELECTOR_TAG_NAME, 'selectstate')
: $param->find('select', Locator::SELECTOR_TAG_NAME, 'select');
if ($value->isVisible()) {
$value->setValue($rule);
$this->click();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Mtf\Client\Element;

/**
* @inheritdoc
*/
class SelectstateElement extends SelectElement
{
/**
* @inheritdoc
*/
protected $optionByValue = './/option[normalize-space(.)=%s]';
}

0 comments on commit f59817b

Please sign in to comment.