我在登录表单中有一个提交按钮,即“登录”。输入字段看起来像下面的
<input name="submit" type="submit" value="Log In">
当我按下“登录”按钮提交登录表单时,我收到以下错误
Exception thrown by (//html/.//input[./@type = 'submit' or ./@type = 'image' or ./@type = 'button'][(((./@id = 'submit' or ./@name = 'submit') or contains(./@value, 'submit')) or contains(./@title, 'submit'))] | .//input[./@type = 'image'][contains(./@alt, 'submit')] | .//button[((((./@id = 'submit' or ./@name = 'submit') or contains(./@value, 'submit')) or contains(normalize-space(string(.)), 'submit')) or contains(./@title, 'submit'))] | .//input[./@type = 'image'][contains(./@alt, 'submit')] | .//*[./@role = 'button'][(((./@id = 'submit' or ./@name = 'submit') or contains(./@value, 'submit')) or contains(./@title, 'submit') or contains(normalize-space(string(.)), 'submit'))])[1]
Element must be displayed to click (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 44 milliseconds
Build info: version: '2.31.0', revision: '1bd294d', time: '2013-02-27 20:52:59'
System info: os.name: 'Windows Server 2008 R2', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_35'
Session ID: a5c41be673ac14346462e1bf99f60995
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=XP, chrome.chromedriverVersion=26.0.1383.0, acceptSslCerts=false, javascriptEnabled=true, browserName=chrome, rotatable=false, locationContextEnabled=false, version=27.0.1453.110, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=false, takesScreenshot=true}]
我的步骤如下:
Given I am on "/"
And I wait for "Log In"
And I hover on "Log In"
And I wait for "Log In"
When I fill in "LoginForm_username" with my username
And I fill in "LoginForm_password" with my password
And I press "submit"
答案 0 :(得分:3)
我修改了代码,因为它现在正在工作
$page = $this->getSession()->getPage();
$element = $page->find('css',"#formid input[value=\"Log In\"]");
$element->doubleClick();
答案 1 :(得分:2)
可能使用另一个xpath定位器?尝试:.//input[@value='Log In']