Mink/Goutte如何在Goutte中选中不带属性的复选框? [英] Mink/Goutte How to check checkbox without attribute in Goutte?

查看:95
本文介绍了Mink/Goutte如何在Goutte中选中不带属性的复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我事先表示歉意,但是我是个初学者. 我尝试选中不带ID或名称的复选框.

I apologize in advance but I am very beginner. I try to check checkbox without id or name.

<span class="ps-align-left">
<input type="checkbox" value="43899" style="background-color: rgb(252, 252, 252);"/>
                                            43899
</span>

我弄清楚了如何使用selenium2driver.所以我像这样使用函数"find":

I figure out how to do it with selenium2driver. So I use function "find" like this:

public function checkOption()
{
    $this->getSession()->getPage()->find('css', '.ps-align-left>input')->check();
}

它运行正常,但是当我尝试使用无头浏览器Goutte运行测试时,出现错误:

And it works fine but when I try to run test with headless browser Goutte I get error:

/usr/bin/php5.6 /tmp/ide-behat.php --format PhpStormBehatFormatter /home/grzegorz/PhpstormProjects/Test/features/scenariusze.feature
Testing started at 14:48 ...

Malformed field path ""

有人知道原因吗?我应该使用其他功能吗?

Can anyone knows the reason? Should I use a different function?

推荐答案

您必须使用MinkContext的方法checkOption($option)(在Behat/MinkExtension中,必须通过Composer安装).

You have to use the method checkOption($option) of MinkContext (in Behat/MinkExtension that you must install via Composer).

MinkContext默认安装在Behat环境中.

MinkContext is installed by default in Behat environment.

MinkContext.php

希望它能起作用.

这篇关于Mink/Goutte如何在Goutte中选中不带属性的复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆