Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use Behat\Behat\Context\Context;
- use Behat\Behat\Context\SnippetAcceptingContext;
- use Behat\Behat\Context\TranslatedContextInterface;
- use Behat\Gherkin\Node\PyStringNode;
- use Behat\Gherkin\Node\TableNode;
- use Behat\MinkExtension\Context\MinkContext;
- use Behat\Mink\Mink;
- use Behat\Mink\Driver\GoutteDriver;
- use behat\Mink\Session;
- /**
- * Defines application features from the specific context.
- */
- class FeatureContext extends MinkContext
- {
- protected $session;
- protected $typ;
- /**
- * Initializes context.
- *
- * Every scenario gets its own context instance.
- * You can also pass arbitrary arguments to the
- * context constructor through behat.yml.
- */
- /**
- * @Given Wchodze na strone :arg1
- */
- public function wchodzeNaStrone($arg1)
- {
- // Choose a Mink driver.
- $driver = new \Behat\Mink\Driver\GoutteDriver();
- $this->session = new \Behat\Mink\Session($driver);
- // start the session
- $this->session->start();
- $this->session->visit('http://examinechina.local/app_dev.php/');
- }
- /**
- * @When Wciskam przycisk :arg1
- */
- public function wciskamPrzycisk($arg1)
- {
- $bol=1;
- $bol=$this->session->getPage();
- $przycisk=$bol->find('css','.button-orange')->click();
- $sprawdzenie1 = $this->session->getCurrentUrl();
- $url="http://examinechina.local/app_dev.php/order-report";
- if($sprawdzenie1 !== $url){
- throw new exception("Nuuu ni kaak... U mnie jest: " . $sprawdzenie1);
- }
- }
- /**
- * @When Wypelniam pole company name :arg1
- */
- public function wypelniamPoleCompanyName($arg1)
- {
- $bol=1;
- //nazwa firmy chinskiej
- $bol=$this->session->getPage();
- $companyname = $bol->find('css','INPUT#client_reports_0_name');
- if($companyname===NULL){
- throw new exception("Nie ma pola company name");
- }else
- {
- $companyname->setValue($arg1);
- }
- }
- /**
- * @When Wybieram opcje :arg1
- */
- public function wybieramOpcje($arg1)
- {
- $str=1;
- $str=$this->session->getPage();
- if($arg1 === "1 One" || $arg1=== "72h" || $arg1=== "Dragon"){
- $szukamy = $str->find('css','INPUT#client_reports_0_speed')->setValue($arg1);
- echo "wybrano opcje cenowa: " . $arg1;
- }else{
- throw new exception("Nie ma takiej opcji cenowej jak: " . $arg1);
- }
- }
- /**
- * @When Wypelniam pole name :arg1
- */
- public function wypelniamPoleName($arg1)
- {
- $bil=1;
- $bil=$this->session->getPage();
- //nazwa klienta
- $name = $bil->find('css', 'INPUT#client_name');
- if($name === null){
- throw new exception("Nie ma pola client name");
- }
- $name->setValue($arg1);
- }
- /**
- * @When Wypelniam pole phone :arg1
- */
- public function wypelniamPolePhone($arg1)
- {
- $bal=1;
- $bal=$this->session->getPage();
- //telefon
- $phone = $bal->find('css', 'INPUT#client_phone');
- if($phone ===null){
- throw new exception("Nie ma pola phone");
- }
- $phone->setValue($arg1);
- }
- /**
- * @When wypelniam pole email :arg1
- */
- public function wypelniamPoleEmail($arg1)
- {
- $bsl=1;
- $bsl=$this->session->getPage();
- //email
- $email = $bsl->find('css', 'INPUT#client_email');
- if($email ===null){
- throw new exception("Nie ma pola email");
- }
- $email->setValue($arg1);
- }
- /**
- * @When Wybieram czy chce fakture :arg1
- */
- public function wybieramCzyChceFakture($arg1)
- {
- $omnom=1;
- $omnom=$this->session->getPage();
- $faktura=$omnom->find('css', 'INPUT#client_invoice');
- $faktura->getValue();
- if($arg1 ==="tak"){
- if($faktura->isChecked()){
- echo "wybrano fakture (domyslnie)";
- }
- else { $faktura->check();
- echo "wybrano fakture";}
- }
- if($arg1==="nie"){
- if($faktura->isChecked()){
- $faktura->uncheck();
- echo "Nie chcesz fakturki? :<";
- }
- else{
- echo "Nie chcesz fakturki? :<<<";
- }
- }
- }
- /**
- * @When Wybieram typ platnosci :arg1
- */
- public function wybieramTypPlatnosci($arg1)
- {
- return $this->typ=$arg1;
- }
- /**
- * @When naciskam przycisk :arg1
- */
- public function naciskamPrzycisk2($arg1)
- {
- //wcisniecie przycisku "order raport"
- $bzl=1;
- $bzl=$this->session->getPage();
- if($this->typ==="paypal"){
- $button= $bzl->find('css','#submit_paypal > button:nth-child(1)')->click();
- }
- if($this->typ==="przelew"){
- $button=$bzl->find('css','#submit_bank > button:nth-child(1)')->click();
- }
- }
- /**
- * @Then Powinienem zobaczyc :arg1
- */
- public function powinienemZobaczyc($arg1)
- {
- $trytka=1;
- $trytka=$this->session->getCurrentUrl();
- echo $trytka;
- $text=$this->session->getPage()->find('xpath','//h3[text()="Thank you for ordering a credit report from ExamineChina."]');
- if($text===null){
- throw new exception("no nie udalo sie...");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement