@@ -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 ();
0 commit comments