Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AnalyticsForm.php
Go to the documentation of this file.
1 <?php
7 
8 use Magento\Mtf\Block\Form;
9 use Magento\Mtf\Client\Locator;
10 
15 class AnalyticsForm extends Form
16 {
20  private $analyticsStatus = '#analytics_general_enabled';
21 
25  private $analyticsStatusLabel = '#row_analytics_general_enabled > td.value > p > span';
26 
30  private $submitButton = '#save';
31 
35  private $analyticsVertical = '#analytics_general_vertical';
36 
40  private $analyticsVerticalScope = '#row_analytics_general_vertical span[data-config-scope="[WEBSITE]"]';
41 
45  private $sendDataTimeHh = '#row_analytics_general_collection_time > td.value > select:nth-child(2)';
46 
50  private $sendDataTimeMm = '#row_analytics_general_collection_time > td.value > select:nth-child(3)';
51 
55  private $sendDataTimeSs = '#row_analytics_general_collection_time > td.value > select:nth-child(4)';
56 
60  private $timeZone =
61  '#row_analytics_general_collection_time > td.value > p > span';
62 
66  public function isAnalyticsEnabled()
67  {
68  return $this->_rootElement->find($this->analyticsStatus, Locator::SELECTOR_CSS)->getValue();
69  }
70 
75  public function analyticsToggle($state = 'Enable')
76  {
77  return $this->_rootElement->find($this->analyticsStatus, Locator::SELECTOR_CSS, 'select')->setValue($state);
78  }
79 
83  public function saveConfig()
84  {
85  return $this->browser->find($this->submitButton)->click();
86  }
87 
91  public function getAnalyticsStatus()
92  {
93  return $this->_rootElement->find($this->analyticsStatusLabel, Locator::SELECTOR_CSS)->getText();
94  }
95 
100  public function setAnalyticsVertical($vertical)
101  {
102  return $this->_rootElement->find($this->analyticsVertical, Locator::SELECTOR_CSS, 'select')
103  ->setValue($vertical);
104  }
105 
111  public function setTimeOfDayToSendData($hh, $mm)
112  {
113  $this->_rootElement->find($this->sendDataTimeHh, Locator::SELECTOR_CSS, 'select')
114  ->setValue($hh);
115  $this->_rootElement->find($this->sendDataTimeMm, Locator::SELECTOR_CSS, 'select')
116  ->setValue($mm);
117  return $this;
118  }
119 
123  public function getTimeOfDayToSendDate()
124  {
125  $hh = $this->_rootElement->find($this->sendDataTimeHh, Locator::SELECTOR_CSS, 'select')
126  ->getValue();
127  $mm = $this->_rootElement->find($this->sendDataTimeMm, Locator::SELECTOR_CSS, 'select')
128  ->getValue();
129  $ss = $this->_rootElement->find($this->sendDataTimeSs, Locator::SELECTOR_CSS, 'select')
130  ->getValue();
131  return sprintf('%s, %s, %s', $hh, $mm, $ss);
132  }
133 
137  public function getTimeZone()
138  {
139  return $this->_rootElement->find($this->timeZone, Locator::SELECTOR_CSS)
140  ->getText();
141  }
142 
146  public function getAnalyticsVertical()
147  {
148  return $this->_rootElement->find($this->analyticsVertical, Locator::SELECTOR_CSS)->getValue();
149  }
150 
154  public function getAnalyticsVerticalScope()
155  {
156  return $this->_rootElement->find($this->analyticsVerticalScope, Locator::SELECTOR_CSS)->isVisible();
157  }
158 }