Google chrome 使用robotframework在google中搜索项目
我无法理解如何设置robotframework的脚本在google上进行简单搜索 这是我的剧本:Google chrome 使用robotframework在google中搜索项目,google-chrome,typescript,testing,automated-tests,robotframework,Google Chrome,Typescript,Testing,Automated Tests,Robotframework,我无法理解如何设置robotframework的脚本在google上进行简单搜索 这是我的剧本: *** Settings *** Documentation This is a basic test Library Selenium2Library *** Variables *** ${url}
*** Settings ***
Documentation This is a basic test
Library Selenium2Library
*** Variables ***
${url} https://www.google.com
${browser} chrome
${text} xpath=//*[@id="lst-ib"]
*** Test Cases ***
User can open page
[Documentation] As a user I can open the
google page
open browser ${URL} ${BROWSER}
wait until page contains ${url}
close browser
User fill in the Search text box
[Documentation] The user search 'Test
Definition'
open browser ${URL} ${browser}
wait until page contains ${URL}
input text ${text} Test Definition
click button btnK
wait until page contains Test
你能告诉我哪里出了错吗?我假设关键字前没有空格是无意的。对我来说,只有提交按钮没有使用正确的路径。因此,这是我更改并添加的
关闭浏览器
。下面的例子对我很有用
*** Settings ***
Documentation This is a basic test
Library Selenium2Library
*** Variables ***
${url} https://www.google.com
${browser} chrome
${text} xpath=//*[@id="lst-ib"]
${search_button} css=input.lsb
*** Test Cases ***
User can open page
[Documentation] As a user I can open the google page
open browser ${URL} ${BROWSER}
wait until page contains ${url}
close browser
User fill in the Search text box
[Documentation] The user search 'Test Definition'
open browser ${URL} ${browser}
wait until page contains ${URL}
input text ${text} Test Definition
click element ${search_button}
wait until page contains Test
sleep 5s
Close Browser
参加聚会可能会迟到,但我认为你的xpath不正确。输入css,如下所示
*** Variables ***
| ${GoogleBaseUrl} | https://www.google.com/
| ${GoogleForm} | css=form[name=f]
| ${GoogleQuery} | css=input[name=q]
*** KeyWords ***
Open Google Search
open browser ${GoogleBaseUrl} firefox gl
wait until element is visible ${GoogleForm}
wait until element is visible ${GoogleQuery}
然后你只需要确保你总是回到主页
Do Google Search
[Arguments] ${term}
log to console Do Google Search with "${term}"
switch browser gl
go to ${GoogleBaseUrl}
wait until element is visible ${GoogleForm}
wait until element is visible ${GoogleQuery}
input text ${GoogleQuery} ${EMPTY}
input text ${GoogleQuery} ${term}
submit form
运行此测试时会发生什么,它与您期望的有什么不同?我有以下错误:WebDriverException:消息:未知错误:元素在点(516411)处不可单击。其他元素将收到单击:。。。(会话信息:chrome=62.0.3202.94)(驱动程序信息:chromedriver=2.30.477690(c53f4ad87510ee97b5c3425a14c0e79780cdf262),platform=Mac OS X 10.12.6 x86_64)错误告诉您有用的信息——输入框顶部有东西。