如何实现robot framework 无界面UI自动化测试

如题。看到一篇文章的介绍的方式是安装phantomjs实现,步骤如下:
1.安装phantomjs以后配置环境变量
2.进入robot文件所在文件夹,用命令行启动robot文件
但是尝试后,还是打开了浏览器。
文章链接:https://www.jianshu.com/p/ba3...

阅读 6.5k
1 个回答

用headless模式运行webdrive来后台启动browser.

option = webdriver.ChromeOptions()
option.add_argument("headless")
# driver = webdriver.Chrome(r'C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe',chrome_options=option)
# print(driver.title)
driver = webdriver.Chrome(r'C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe',chrome_options=option)
# driver.get('https://segmentfault.com/q/1010000015379801?utm_source=tag-newest')
driver.get('https://www.baidu.com/')
print(driver.title)
time.sleep(5) # Let the user actually see something!
search_box = driver.find_element_by_name('wd')
search_box.send_keys('ChromeDriver')
search_box.submit()
time.sleep(5) # Let the user actually see something!
driver.quit()

图片描述

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进