如何使用selenium webdriver从ruby中的选择列表中选择多个选项

时间:2016-09-27 09:28:45

标签: ruby selenium select selenium-webdriver selenium-ruby

我想选择多个选项。

然后我想验证它是否被选中?

这是我的代码:

require 'selenium-webdriver'

class Ques7
  def test_multiple_select
    driver = Selenium::WebDriver.for :firefox
    driver.get(url)
    driver.find_element(:xpath, './/*[@id="select_1"]').click
    puts driver.find_element(:xpath, './/*[@id="select_1"]').selected?
    driver.find_element(:xpath, './/*[@id="select_2"]').click
    driver.find_element(:xpath, './/*[@id="select_4"]').click
    puts driver.find_element(:xpath =>'.//*[@id="select_1"]',
    :xpath => './/*[@id="select_2"]',:xpath => './/*[@id="select_4"]').selected?
  end
end

obj = Ques7.new
obj.test_multiple_select

0 个答案:

没有答案