How do I set an option as selected using Selenium WebDriver (selenium 2.0) client in ruby

前端 未结 10 1332
难免孤独
难免孤独 2020-12-14 00:46

I am trying to get familiar with the new ruby selenium-webdriver as it appears more intuitive mostly than the previous version of selenium and the ruby driver that went with

10条回答
  •  既然无缘
    2020-12-14 00:57

    Ruby Code with Example:

    require "selenium-webdriver"
    
    driver = Selenium::WebDriver.for :ie
    
    driver.navigate.to "http://google.com"
    a=driver.find_element(:link,'Advanced search')
    
    a.click
    
    
    a=driver.find_element(:name,'num')
    
    options=a.find_elements(:tag_name=>"option")
    options.each do |g|
      if g.text == "20 results"
      g.click
      break
      end
    end
    

提交回复
热议问题