'm using Chrome: 60.0.3112.101 64 bits, ChromeDriver 2.29.461571, selenium-webdriver: 3.4 and cucumber 2.4. I'm performing test automation, I'm using the Ruby language with the webdriver and cucumber frameworks in ubuntu 16.04. I can not automate clicking the button.Why is this happening? Or am I forgetting something? I am using the following code. Any help is appreciated.
使用Chrome:60.0.3112.101 64位,ChromeDriver 2.29.461571,selenium-webdriver:3.4和黄瓜2.4。我正在执行测试自动化,我在ubuntu 16.04中使用Ruby语言和webdriver和黄瓜框架。我无法自动点击按钮。为什么会发生这种情况?还是我忘记了什么?我使用以下代码。任何帮助表示赞赏。
Quando(/^clicar o botão "([^"]*)"$/) do |botaoSalvar| @navegador.find_element(:id, botaoSalvar).click end
Quando(/ ^ clicarobobão“([^”] *)“$ /)do | botaoSalvar | @navegador.find_element(:id,botaoSalvar).click end
E clicar o botão "SAVE"
# features/step_definitions/criarConta.rb:92
unknown error: Element <input title="Save" accesskey="a" class="button primary"
onclick="var _form = document.getElementById('EditView');
_form.action.value='Save'; if(check_form('EditView'))
SUGAR.ajaxUI.submitForm(_form);return false;" type="submit" name="button"
value="Save" id="SAVE"> is not clickable at point (287, 20).
Other element would receive the click:
其他元素将收到点击:
<a href="#" id="grouptab_1" class="dropdown-toggle grouptab" data-toggle="dropdown">...</a>
(Session info: chrome=60.0.3112.101)
(Driver info: chromedriver=2.29.461571
(8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.10.0-33-generic x86_64)
(Selenium::WebDriver::Error::UnknownError)
./features/step_definitions/criarConta.rb:93:in `/^clicar o botão "([^"]*)"$/'
features/criarConta.feature:30:in `E clicar o botão "SAVE"'
Então a conta será cadastrada corretamente
# features/criarConta.feature:31
Failing Scenarios: cucumber features/criarConta.feature:7 # Cenário: Cadastrando uma conta
失败的场景:黄瓜特色/ criarConta.feature:7#Cenário:Cadastrando uma conta
2 个解决方案
#1
1
I sometimes encountered scenarios where the capybara driver would render the page differently from an actual browser, resulting in elements being obscured by others or rendered outside the viewport.
我有时会遇到这样的情况,即水豚驱动程序会以不同于实际浏览器的方式呈现页面,从而导致元素被其他人遮挡或在视口外呈现。
In these cases, calling .click
on them would result in errors like this one. Have you tried replacing .click
with .trigger("click")
? That usually did the trick for me.
在这些情况下,调用.click会导致像这样的错误。你试过用.trigger替换.click(“点击”)吗?这通常对我有用。
#2
0
I did not make it
我没有成功
Quando(/^clicar o botão "([^"])"$/) do |botaoSave| @navegador.find_elements(:xpath, "//[@id='SAVE']").trigger("click") end
Quando(/ ^ clicarobobão“([^”])“$ /)do | botaoSave | @ navegador.find_elements(:xpath,”// [@ id ='SAVE']“)。turigger(”click“)结束
E clicar o botão "SAVE" # features/step_definitions/criarConta.rb:92
undefined method `trigger' for #<Array:0x00000002bb1730> (NoMethodError)
./features/step_definitions/criarConta.rb:93:in `/^clicar o botão "([^"]*)"$/'
features/criarConta.feature:30:in `E clicar o botão "SAVE"'
Então a conta será cadastrada corretamente # features/criarConta.feature:31
Failing Scenarios:
cucumber features/criarConta.feature:7 # Cenário: Cadastrando uma conta
#1
1
I sometimes encountered scenarios where the capybara driver would render the page differently from an actual browser, resulting in elements being obscured by others or rendered outside the viewport.
我有时会遇到这样的情况,即水豚驱动程序会以不同于实际浏览器的方式呈现页面,从而导致元素被其他人遮挡或在视口外呈现。
In these cases, calling .click
on them would result in errors like this one. Have you tried replacing .click
with .trigger("click")
? That usually did the trick for me.
在这些情况下,调用.click会导致像这样的错误。你试过用.trigger替换.click(“点击”)吗?这通常对我有用。
#2
0
I did not make it
我没有成功
Quando(/^clicar o botão "([^"])"$/) do |botaoSave| @navegador.find_elements(:xpath, "//[@id='SAVE']").trigger("click") end
Quando(/ ^ clicarobobão“([^”])“$ /)do | botaoSave | @ navegador.find_elements(:xpath,”// [@ id ='SAVE']“)。turigger(”click“)结束
E clicar o botão "SAVE" # features/step_definitions/criarConta.rb:92
undefined method `trigger' for #<Array:0x00000002bb1730> (NoMethodError)
./features/step_definitions/criarConta.rb:93:in `/^clicar o botão "([^"]*)"$/'
features/criarConta.feature:30:in `E clicar o botão "SAVE"'
Então a conta será cadastrada corretamente # features/criarConta.feature:31
Failing Scenarios:
cucumber features/criarConta.feature:7 # Cenário: Cadastrando uma conta