【发布时间】:2016-06-10 09:24:15
【问题描述】:
我正在使用 Selenium Webdriver、Chromedriver 和 Nokogiri。我编写了一个脚本来访问 Google.com 并解析页面:
require "selenium-webdriver"
require "nokogiri"
browser = Selenium::WebDriver.for :chrome
browser.get "https://google.com"
doc = Nokogiri::HTML.parse(browser.page_source)
现在,如何使用我的 ruby 脚本在搜索栏中输入文本?搜索栏的 ID 为 #lst-ib。
【问题讨论】:
-
Selenium 已经提供了很多方法来定位页面的 HTML 部分。通过使用 Nokogiri,您可以定位相同的元素,但无法与找到的元素交互
标签: ruby xml selenium automation nokogiri