[英]Selenium webdriver zoom with Ruby for Chrome
I am executing automated tests with cucumber and the selenium webdriver connected to Google Chrome and I need to change the zoom at the browser to avoid errors at some automated tests. 我正在使用Cucumber和连接到Google Chrome的Selenium Webdriver执行自动化测试,并且需要更改浏览器的缩放比例,以避免某些自动化测试出错。
The zoom can be changed by pressing the keys Control + '-' or Control + '-' . 可以通过按Control +'-'或Control +'-'键来更改缩放比例。
In order to simulate the pressing of theese keys I have added a Hook with this code: 为了模拟按下这些按键,我添加了一个带有以下代码的挂钩:
Before ('@ChangeBrowserZoom') do
page = Capybara::page
page.find("html").send_keys(:control , '+')
page.find("body").native.send_keys(:control , '+')
end
The hook is been called but it is not working. 该挂钩已被调用,但无法正常工作。
Selenium send_keys method call args one by one in your code. Selenium send_keys方法在您的代码中一一调用args。 For calling it together use square brackets: 要一起调用,请使用方括号:
Before ('@ChangeBrowserZoom') do
page = Capybara::page
page.find("html").send_keys([:control , :add])
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.