コード例 #1
0
ファイル: FastSelectTest.php プロジェクト: magium/magium
 public function testClearSelectedOptions()
 {
     $this->writePage();
     $this->webdriver->byXpath('//*[@id="select"]/option[1]')->click();
     $fast = new FastSelectElement($this->webdriver, '//select[@id="select"]');
     $fast->clearSelectedOptions();
     $result = $fast->getSelectedOptions();
     self::assertCount(0, $result);
 }
コード例 #2
0
ファイル: ByTextTest.php プロジェクト: magium/magium
 public function testOptionWithParentSelector()
 {
     $this->writePage();
     $element = $this->byText('Some Text', null, '//select[@id="select2"]');
     $element->click();
     $select = new FastSelectElement($this->webdriver, '//select[@id="select2"]');
     $options = $select->getSelectedOptions();
     $option = array_shift($options);
     self::assertEquals('Some Text', $option['label']);
 }
コード例 #3
0
 protected function enablePaymentMethod($action, $id)
 {
     $this->getAction(Login::ACTION)->login();
     $this->getNavigator(AdminMenu::NAVIGATOR)->navigateTo('System/Configuration');
     $paymentMethod = $this->getAction($action);
     /* @var $paymentMethod \Magium\Magento\Actions\Admin\Configuration\PaymentMethods\CashOnDelivery */
     $paymentMethod->setEnabled(SettingModifier::SETTING_OPTION_YES);
     $paymentMethod->execute();
     $this->getNavigator(SystemConfiguration::NAVIGATOR)->navigateTo('General/Merchant Location');
     $this->getNavigator(SystemConfiguration::NAVIGATOR)->navigateTo('Payment Methods/' . $paymentMethod::NAME);
     $select = new FastSelectElement($this->webdriver, sprintf('//select[@id="%s"]', $id));
     $options = $select->getSelectedOptions();
     self::assertCount(1, $options);
     self::assertEquals(1, $options[0]['value']);
 }
コード例 #4
0
 protected function handleElementSetting($elementId, $value)
 {
     $element = $this->webDriver->byId($elementId);
     if (strtolower($element->getTagName()) === 'select') {
         if (!is_array($value)) {
             $value = [$value];
         }
         $xpath = sprintf('//select[@id="%s"]', $elementId);
         $select = new FastSelectElement($this->webDriver, $xpath);
         //            $options = $select->getAllSelectedOptions();
         $select->clearSelectedOptions();
         foreach ($value as $v) {
             $xpath = sprintf('//select[@id="%s"]', $elementId);
             $matches = null;
             if (preg_match('/^label=(.+)$/', $v, $matches)) {
                 $xpath .= sprintf('/descendant::option[.="%s"]', str_replace('"', '\\"', $matches[1]));
                 $this->webDriver->byXpath($xpath)->click();
             } else {
                 $xpath .= sprintf('/descendant::option[@value="%s"]', str_replace('"', '\\"', $v));
                 $this->webDriver->byXpath($xpath)->click();
             }
         }
     } else {
         if (strtolower($element->getTagName()) === 'input') {
             if ($element->getAttribute('value') != $value) {
                 $element->clear();
                 $element->sendKeys($value);
                 $this->dataChanged = true;
             }
         }
     }
 }