phpunit硒自动化测试

phpunit selenium automated tests

本文关键字:自动化测试 phpunit      更新时间:2024-04-18

我正在设置在网站上运行的自动测试,以确保一切正常工作。我有一个网页显示了一张记录表。

  1. 我想测试加载选定的网页
  2. 选中所选记录的复选框
  3. 选择"处理所选内容"按钮
  4. 在文本区域输入一些伪文本
  5. 单击"确认"保存记录

我已经完成了前3个步骤,但我仍停留在第4步。有人能帮忙吗?谢谢Conor

<?php
    class AdminUserProcessSelectedNote extends PHPUnit_Extensions_Selenium2TestCase{
        public function setUp()
        {
            $this->setHost('localhost'); // Set the hostname for the connection to the Selenium server.
            $this->setPort(4444); // set port # for connection to selenium server
            $this->setBrowser('firefox'); // set the browser to be used
            $this->setBrowserUrl('http://www.myhost.com/');  // set base URL for tests
        }
        public function testAdminUserProcessSelectedNoteSelectReq3()
        {            
            $this->url('index.php'); // Set the URL to access the page
        // Select the specific checkbox with the Id
            $viewReqsCheckbox = $this->byId('jqg_requestGrid_request_4506');
        $viewReqsCheckbox ->click();
        // Now, Select the Process Selected button
            $processSelectedBtn = $this -> byId('processStateChangeButton');
        $processSelectedBtn ->click();
        // Make a note and Confirm
        $this->byName('dlg-stateChange-notes');        
        $this->setField('dlg-stateChange-notes','TEST NOTE');  
        $this->click('Confirm');  
    }
    }
?>

问题是:没有名为setField的方法。改变

$this->setField('dlg-stateChange-notes','TEST NOTE');  

$this->sendKeys('dlg-stateChange-notes','TEST NOTE');  

如果不起作用,请尝试使用

$this->type('dlg-stateChange-notes','TEST NOTE');  

//byId、byClassName、byXpath您可以设置值。

 $this->byId('dlg-stateChange-notes')->value('TEST NOTE');