【发布时间】:2019-06-18 08:33:26
【问题描述】:
当我在浏览器的输入字段中键入关键字以查看结果时,我正在设置一个简单的检查。 并且当在 javascript 部分开始检查时,检查会花费很长时间以完成错误。
我正在使用:Linux RedHat 7 行为 3.5.0 Selenium 独立服务器 3.141.59 貂皮1.6
# behat.yml
default:
extensions:
Behat\MinkExtension:
browser_name: chrome
goutte: ~
javascript_session: selenium2
selenium2:
wd_host: http://99.80.48.204:4444/wd/hub
capabilities: { "browser": "chrome", "version": "*", 'chrome': {'switches':['--start-maximized']}}
base_url: https://www.bing.com
suites:
ui:
contexts: [FeatureContext, WebContext]
#Webcontext.php
<?php
use Behat\MinkExtension\Context\MinkContext;
class WebContext extends MinkContext {
/**
*@When I wait for :arg1 seconds
*/
public function iWaitForSeconds($args)
{
$this->getSession()->wait($args * 1000);
}
/**
* @When I fill in :arg1 with: :arg2
*/
public function iFillInWith($value, $field)
{
$javascript = "window.onload = function () {var e = document.getElementById('$field').value='$value';}";
$this->getSession()->executeScript($javascript);
}
}
# bing.feature
@insulated
Feature: Bing
Scenario: Homepage
Given I am on the homepage
Then I should see "Bing"
And I should see "Images"
And I should see "Office Online"
@javascript
Scenario: Search
Given I am on the homepage
When I fill in "sb_form_q" with "grafikart"
And I wait for 1 seconds
Then I should see "Grafikart.fr"
我希望快速检查,我的所有线路都是绿色的,但目前它不起作用。
【问题讨论】:
-
你得到什么错误?你用什么命令运行的?
-
我用 bin/behat 运行,当检查时当我用“grafikart”填写“sb_form_q”时.....错误是:未找到 ID|名称|标签|值|占位符“sb_form_q”的表单字段。 (Behat\Mink\Exception\ElementNotFoundException)