public function runScript(Script $script) { $this->addInfo("Starting browser"); $this->session->start(); $chromeheight = 144 / 2; $this->addInfo("Resizing browser " . $this->getWidth() . "x" . $this->getHeight()); $this->session->resizeWindow($this->getWidth(), $this->getHeight() + $chromeheight, null); foreach ($script->getSteps() as $step) { $step->execute($this); } $this->addInfo("Closing browser"); $this->session->stop(); $this->addInfo("Done"); }
public function load($filename, $shooter) { $xml = simplexml_load_file($filename); $script = new Script(); $script->setName((string) $xml['name']); foreach ($xml->Steps->children() as $stepnode) { $type = $stepnode->getName(); $className = "Screenshot\\Step\\" . $type . "Step"; $step = new $className($shooter); foreach ($stepnode->attributes() as $key => $value) { $setter = 'set' . ucfirst((string) $key); $step->{$setter}((string) $value); } $script->addStep($step); } return $script; }
public function load($filename, $shooter) { $json = file_get_contents($filename); $data = json_decode($json, true); //print_r($data); $script = new Script(); $script->setName($data['name']); foreach ($data['steps'] as $stepdata) { $type = $stepdata['type']; $p = $stepdata['parameters']; $className = "Screenshot\\Step\\" . $type . "Step"; $step = new $className($shooter); foreach ($stepdata['parameters'] as $key => $value) { $setter = 'set' . ucfirst($key); $step->{$setter}($value); } $script->addStep($step); } //print_r($script); exit(); return $script; }