小编Nak*_*lda的帖子

如何从命令行将环境变量传递给 Codeception YML 文件?

我总是在 Codeception YML 文件中看到这种事情:

modules:
    enabled:
        - PhpBrowser:
            url: '%URL%'
Run Code Online (Sandbox Code Playgroud)

如何从命令行将“URL”传递给 Codeception?或者任何其他方式!

codeception

9
推荐指数
1
解决办法
8465
查看次数

为什么Codeception为每个test*方法创建新的\ Test实例?

作为基础,我使用\ Codeception\TestCase\Test类.

我注意到,对于类中定义的每个test*方法,codeception都会重新创建TestCase\Test类!

但为什么?

结果我不能使用类字段!

public function getName() {
    if (!empty($this->_name)) {
        return $this->_name;
    } else $this->_name = uniqid('_name');
}
Run Code Online (Sandbox Code Playgroud)

每个测试方法的getName()都会返回新生成的名称..这对我来说是错误的行为.如果我想为每个测试方法使用类字段,就像普通的OOP一样,可以解决这种情况吗?

codeception

6
推荐指数
0
解决办法
189
查看次数

Codeception AcceptanceTester :: loadSessionSnapshot未定义

我正在尝试测试项目但由于此错误而无法检查登录页面:

[RuntimeException] Call to undefined method AcceptanceTester::loadSessionSnapshot

这是我的代码:

<?php 
$I = new AcceptanceTester($scenario);
$I->wantTo('Login');
$I->amOnPage('/');
if($I->loadSessionSnapshot('loggedin')) exit();
$I->dontSee('NotFound');
//$I->dontSee('Error');
$csrf = $I->grabCookie('_token');
$I->submitForm('.form',array('login'=>array(
        'username'=>'username',
        'password'=>'*******'
    )
));
$I->saveSessionSnapshot('loggedin');
$I->see('username');
Run Code Online (Sandbox Code Playgroud)

我的配置是这样的

# Codeception Test Suite Configuration
#
# Suite for acceptance tests.
# Perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate suite.

class_name: AcceptanceTester
modules:
    enabled:
        - PhpBrowser:
            url: http://myweb.com
        - \Helper\Acceptance
Run Code Online (Sandbox Code Playgroud)

我使用命令行命令生成了它

codecept.bat generate:cept acceptance loginTest
Run Code Online (Sandbox Code Playgroud)

codeception

6
推荐指数
1
解决办法
996
查看次数

Selenium 无效参数

我正在尝试设置代码接收。

运行任何验收测试时,我收到以下错误:

> 1) FirstCest: Test
 Test  tests\acceptance\FirstCest.php:tryToTest

  [Facebook\WebDriver\Exception\InvalidArgumentException] invalid argument
  (Session info: chrome=81.0.4044.92)


Scenario Steps:

 1. $I->amOnPage("/") at tests\acceptance\FirstCest.php:14

#1  C:\Users\USER\Desktop\Test\Programming test\vendor\php-webdriver\webdriver\lib\Exception\WebDriverException.php:99
#2  C:\Users\USER\Desktop\Test\Programming test\vendor\php-webdriver\webdriver\lib\Remote\HttpCommandExecutor.php:370
#3  C:\Users\USER\Desktop\Test\Programming test\vendor\php-webdriver\webdriver\lib\Remote\RemoteWebDriver.php:590
#4  C:\Users\USER\Desktop\Test\Programming test\vendor\php-webdriver\webdriver\lib\Remote\RemoteWebDriver.php:252
#5  Codeception\Module\WebDriver->amOnPage
#6  C:\Users\USER\Desktop\Test\Programming test\tests\_support\_generated\AcceptanceTesterActions.php:305
#7  C:\Users\USER\Desktop\Test\Programming test\tests\acceptance\FirstCest.php:14
#8  FirstCest->tryToTest
Artifacts:

Png: C:\Users\USER\Desktop\Test\Programming test\tests/_output\FirstCest.tryToTest.fail.png
Html: C:\Users\USER\Desktop\Test\Programming test\tests/_output\FirstCest.tryToTest.fail.html

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
PS C:\Users\USER\Desktop\Test\Programming test>     
Run Code Online (Sandbox Code Playgroud)

这是我的配置:

class_name: AcceptanceTester
colors: true
modules: 
    enabled:
        - WebDriver
        - Asserts
        - \Helper\Acceptance
    config:
        WebDriver:
            url: 'www.google.com'
            browser: 'chrome'
            window_size: 1280x1280 …
Run Code Online (Sandbox Code Playgroud)

selenium webdriver codeception

6
推荐指数
1
解决办法
2485
查看次数

让WebDriver使用Firefox

使用Laravel 5+和Vagrant.

我用selenium运行:

java -jar vendor/se/selenium-server-standalone/bin/selenium-server-standalone.jar -Dwebdriver.firefox.bin="/usr/bin/firefox"
Run Code Online (Sandbox Code Playgroud)

使用无头显示器:

sudo Xvfb :10 -ac
Run Code Online (Sandbox Code Playgroud)

但是,当我运行代码时:

 ./vendor/bin/codecept run selenium --steps
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

[Facebook\WebDriver\Exception\UnknownServerException] 45000 ms后无法在端口7055上连接到主机127.0.0.1.Firefox控制台输出:错误:GDK_BACKEND与可用显示不匹配

我对我应该使用的服务器和端口感到困惑.目前我访问的网站通过http://localhost:8000 外面的流浪汉.

$url = 'http://localhost:4444/wd/hub'在里面观察api\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php

由于错误输出:

127.0.0.1在端口7055上.

selenium webdriver codeception

5
推荐指数
1
解决办法
3465
查看次数

调用未定义的方法 CI_DB_mysqli_result::results()

我对 CodeIgniter 很陌生。我得到低于错误。有人可以帮我吗。我检查了 StackOverflow 上的各种答案,但没有一个对我有帮助。

An uncaught Exception was encountered

Type: Error

Message: Call to undefined method CI_DB_mysqli_result::results()

Filename: /Applications/XAMPP/xamppfiles/htdocs/CodeIgniter/application/controllers/Stud_controller.php

Line Number: 10

Backtrace:

File: /Applications/XAMPP/xamppfiles/htdocs/codeigniter/index.php
Line: 315
Function: require_once
Run Code Online (Sandbox Code Playgroud)

下面是控制器代码

<?php
Class Stud_controller extends CI_Controller{
    function __construct(){
        parent::__construct();
        $this->load->database();
    }

    public function index(){
        $query = $this->db->get("stud");
        $data['records'] = $query -> results();
        $this->load->view('Stud_view',$data);
    }
}
?>
Run Code Online (Sandbox Code Playgroud)

这是视图代码

<!DOCTYPE html> 
<html lang = "en">

   <head> 
      <meta charset = "utf-8"> 
      <title>Students Example</title> 
   </head>
   <body>
        <a href = "<?php echo base_url(); ?>
         index.php/stud/add_view">Add</a> …
Run Code Online (Sandbox Code Playgroud)

php codeigniter

1
推荐指数
1
解决办法
9910
查看次数

Codeception REST超时问题

我正在尝试增加Codeception REST超时,但是它似乎没有用。

那就是我所拥有的

class_name: ApiTester
modules:
    enabled:
        - \Helper\Api:
        - REST:
            depends: PhpBrowser
            timeout: 90
Run Code Online (Sandbox Code Playgroud)

我收到超时错误

[GuzzleHttp \ Exception \ ConnectException] cURL错误28:30001毫秒后操作超时,收到0个字节

我究竟做错了什么?

curl codeception

0
推荐指数
1
解决办法
1252
查看次数

exec()php函数无法正常工作

<?php
    error_reporting(0);
    session_start();
    function code($no_of_char)
        {
            $code='';
            $possible_char="0123456789";
            while($no_of_char>0)
                {
                    $code.=substr($possible_char, rand(0, strlen($possible_char)-1), 1);
                    $no_of_char--;
                }
            return $code;
        }

        function sendSms($msg, $to)
        {

        $to=trim($to);
        $m.=urlencode($msg);

   $smsurl="http://bhashsms.com/api/sendmsg.php?user=*****&pass=*****&sender=******&phone=$to&text=$m&priority=ndnd&stype=normal";

    $return = exec($smsurl);
        return $return;
        }

    ?>
Run Code Online (Sandbox Code Playgroud)

print_r($smsurl)显示我想要的绝对正确的命令,但不执行exec($smsurl) 我不熟悉的exec()功能.提前致谢.

php

-1
推荐指数
1
解决办法
79
查看次数

标签 统计

codeception ×6

php ×2

selenium ×2

webdriver ×2

codeigniter ×1

curl ×1