dongritan5654 2018-01-29 14:19
浏览 25
已采纳

Codeception - 如果字段为true则添加+1

public function pickOneRoom(\AcceptanceTester $I)
{
    $I->wantTo('Pick a available room');

    $I->fillField('body > div.mfp-wrap.mfp-close-btn-in.mfp-auto-cursor.mfp-desired-room.mfp-ready > div > div.mfp-content > div > div > div > div.mod-desired-room__filter > div.js-build-desired-choose-room > div.grid.js-desired-room-choose > div > div > div:nth-child(1) > div > input[type="text"]','400');
    $this->checkFavRoom($I);

    if ($I->see('Sorry try again') == true)
    {
        $I->fillField('body > div.mfp-wrap.mfp-close-btn-in.mfp-auto-cursor.mfp-desired-room.mfp-ready > div > div.mfp-content > div > div > div > div.mod-desired-room__filter > div.js-build-desired-choose-room > div.grid.js-desired-room-choose > div > div > div:nth-child(1) > div > input[type="text"]','400++');
    }
}

This is I have come up with till now. I am new to php and not sure how to attack this Problem.

Problem

User Enters a Room number in a field, if that Room is taken, the sorry Message pops up.

This is what i am trying to achieve.

If the Room Nr. is taken so it has to increase by one and check again if its available. Checking is done by $this->checkFavRoom($I);. Number starts at 400 and ends at 445. The Problem is adding one number everytime he sees that text, adding one to the field value, is the tricky part.

Any input is welcome. Thank you.

EDIT:

This is what i came up with, the Problem is that it will not do the second FillField, i really am clueless.

$I->wantTo('Pick a available room');

    $I->fillField('body > div.mfp-wrap.mfp-close-btn-in.mfp-auto-cursor.mfp-desired-room.mfp-ready > div > div.mfp-content > div > div > div > div.mod-desired-room__filter > div.js-build-desired-choose-room > div.grid.js-desired-room-choose > div > div > div:nth-child(1) > div > input[type="text"]','400');
    $this->checkFavRoom($I);
    $I->wait(1);

    if($I->See('Sorry try again') == false)
    {
        $this->submit($I);
    }
    else
    {
        $I->wait(1);
        $I->fillField('body > div.mfp-wrap.mfp-close-btn-in.mfp-auto-cursor.mfp-desired-room.mfp-ready > div > div.mfp-content > div > div > div > div.mod-desired-room__filter > div.js-build-desired-choose-room > div.grid.js-desired-room-choose > div > div > div:nth-child(1) > div > input[type="text"]','402');
        $I->wait(5);
        $this->checkFavRoom($I);
        $this->submit($I);
    }
  • 写回答

2条回答 默认 最新

  • duanpiao6679 2018-01-30 15:40
    关注

    Answer if anyone ever needs it :)

    https://github.com/Codeception/Codeception/issues/4793

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 C语言PE文件遍历节表
  • ¥15 求C# .net4.8小报表工具
  • ¥15 安装虚拟机时出现问题
  • ¥15 Selenium+docker Chrome不能运行
  • ¥15 mac电脑,安装charles后无法正常抓包
  • ¥18 visio打开文件一直显示文件未找到
  • ¥15 请教一下,openwrt如何让同一usb储存设备拔插后设备符号不变?
  • ¥50 使用quartz框架进行分布式任务定时调度,启动了两个实例,但是只有一个实例参与调度,另外一个实例没有参与调度,不知道是为什么?请各位帮助看一下原因!!
  • ¥50 怎么获取Ace Editor中的python代码后怎么调用Skulpt执行代码
  • ¥30 fpga基于dds生成幅值相位频率和波形可调的容易信号发生器。