diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php
index aef6541d645c22ceac86576ea665a48e9267496e..ec2f37205a20d30340f86626c890b11b6b1bedde 100644
--- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php
+++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php
@@ -100,11 +100,11 @@ class Grid extends DataGrid
     {
         $this->openFilterBlock();
         $storeGroupElements = $this->_rootElement->find($this->purchasePointFilter)
-            ->getElements('.//optgroup[./option]', Locator::SELECTOR_XPATH);
+            ->getElements('//option/preceding-sibling::optgroup[1]', Locator::SELECTOR_XPATH);
         $result = [];
 
         foreach ($storeGroupElements as $storeGroupElement) {
-            $result[] = trim($storeGroupElement->getAttribute('label'), ' ');
+            $result[] = trim($storeGroupElement->getAttribute('label'));
         }
 
         return $result;