selenium Select用法笔记

  • select_by value:参数为option中的value属性,例如:HTML代码中 <ignore_js_op> ,应该是value="volvo"这个值,所以应该为小写;
  • select_by_visible_text:参数为option的text值, <ignore_js_op> ,应该是红线标出部分的值,所以应该是大写;
  • Select(driver.find_element_by_name("isImportant")).select_by_visible_text(u"是")

  • deselect_all(self)

| Clear all selected entries. This is only valid when the SELECT supports multiple selections.
| throws NotImplementedError If the SELECT does not support multiple selections

  • select_by_index(self, index)

| Select the option at the given index. This is done by examing the "index" attribute of an
| element, and not merely by counting.
|
| :Args:
| - index - The option at this index will be selected
|
| throws NoSuchElementException If there is no option with specisied index in SELECT

  •  select_by_value(self, value)

| Select all options that have a value matching the argument. That is, when given "foo" this
| would select an option like:
|
| <option value="foo">Bar</option>
|
| :Args:
| - value - The value to match against
|
| throws NoSuchElementException If there is no option with specisied value in SELECT
|

  •  select_by_visible_text(self, text)

| Select all options that display text matching the argument. That is, when given "Bar" this
| would select an option like:
|
| <option value="foo">Bar</option>
|
| :Args:
| - text - The visible text to match against
|
| throws NoSuchElementException If there is no option with specisied text in SELECT

 

posted @ 2017-01-13 14:02  breakcircle  阅读(2374)  评论(0编辑  收藏  举报