"invalid argument: 'id' can not be string" 在 PHP 中尝试 switchToIFrame()
"invalid argument: 'id' can not be string" when trying to switchToIFrame() in PHP
public function switchActionScopeToIframe($name)
{
$this->getdriver()->switchToIFrame($name);
}
$this->switchActionScopeToIframe("my-iframe-name");
我也尝试过从 getSession() 执行此操作。相同的结果。
我也尝试过其他选择器。相同的结果。
我也尝试过像 switchToIFrame(1);
这样的索引,因为我的 iframe 是第二个。这个没有错误,但是它没有在 iframe 中找到任何元素,比如字段。
我也尝试用 javascript 自己重命名 iframe。结果相同。
将此添加到 behat.yml
后有效
capabilities:
extra_capabilities:
goog:chromeOptions:
w3c: false
根据Switch To Frame的规格:
The Switch To Frame command is used to select the current top-level browsing context or a child browsing context of the current browsing context to use as the current browsing context for subsequent commands.
远程步骤为:
设 id 为从参数参数中获取 属性“id”的结果。
如果 id 不为 null、数字对象或表示 Web 元素的对象,return 错误,错误代码无效参数。
如果当前浏览上下文不再打开,return 错误,错误代码不是这样 window。
处理任何用户提示并return它的值,如果它是一个错误。
运行第一个匹配条件的子步骤,如果id代表一个web元素:
- 让元素成为尝试通过网络元素引用 ID 获取已知元素的结果。
- 如果元素陈旧,return 错误代码陈旧元素引用。
- 如果元素不是框架或 iframe 元素,return 错误,错误代码没有这样的框架。
- 将当前浏览上下文设置为元素的嵌套浏览上下文。
对于 Drupal Mink,我添加了这样的功能。
extensions:
Drupal\MinkExtension:
goutte: ~
selenium2:
wd_host: 'http://selenium:4444/wd/hub'
browser: 'chrome'
capabilities:
...
extra_capabilities:
chromeOptions:
w3c: false
...
public function switchActionScopeToIframe($name)
{
$this->getdriver()->switchToIFrame($name);
}
$this->switchActionScopeToIframe("my-iframe-name");
我也尝试过从 getSession() 执行此操作。相同的结果。
我也尝试过其他选择器。相同的结果。
我也尝试过像 switchToIFrame(1);
这样的索引,因为我的 iframe 是第二个。这个没有错误,但是它没有在 iframe 中找到任何元素,比如字段。
我也尝试用 javascript 自己重命名 iframe。结果相同。
将此添加到 behat.yml
后有效 capabilities:
extra_capabilities:
goog:chromeOptions:
w3c: false
根据Switch To Frame的规格:
The Switch To Frame command is used to select the current top-level browsing context or a child browsing context of the current browsing context to use as the current browsing context for subsequent commands.
远程步骤为:
设 id 为从参数参数中获取 属性“id”的结果。
如果 id 不为 null、数字对象或表示 Web 元素的对象,return 错误,错误代码无效参数。
如果当前浏览上下文不再打开,return 错误,错误代码不是这样 window。
处理任何用户提示并return它的值,如果它是一个错误。
运行第一个匹配条件的子步骤,如果id代表一个web元素:
- 让元素成为尝试通过网络元素引用 ID 获取已知元素的结果。
- 如果元素陈旧,return 错误代码陈旧元素引用。
- 如果元素不是框架或 iframe 元素,return 错误,错误代码没有这样的框架。
- 将当前浏览上下文设置为元素的嵌套浏览上下文。
对于 Drupal Mink,我添加了这样的功能。
extensions:
Drupal\MinkExtension:
goutte: ~
selenium2:
wd_host: 'http://selenium:4444/wd/hub'
browser: 'chrome'
capabilities:
...
extra_capabilities:
chromeOptions:
w3c: false
...