【问题标题】:phpunit selenium automated testsphpunit selenium 自动化测试
【发布时间】:2013-12-24 02:01:12
【问题描述】:

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

  1. 我想测试加载所选网页。
  2. 为所选记录选择复选框
  3. 选择“进程选择”按钮
  4. 在文本区域中输入一些虚拟文本
  5. 点击确认保存记录

我已经完成了前 3 个步骤,但我被困在第 4 步。有人可以帮忙吗? 谢谢 康纳

<?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');  
    }
    }
?>

【问题讨论】:

    标签: javascript selenium phpunit


    【解决方案1】:

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

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

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

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

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

    【讨论】:

      【解决方案2】:

      // byId,byClassName,byXpath 可以设置值。

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

      【讨论】:

        猜你喜欢
        • 2020-12-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-01-10
        • 2011-06-22
        • 1970-01-01
        • 2016-04-17
        • 1970-01-01
        相关资源
        最近更新 更多