#!/usr/bin/python
# -*- coding: utf-8 -*-
__author__ = 'zuoanvip'

#下拉框在web页面上非常常见,对于下拉框的处理采用二次定位的方法进行元素定位:首先定位到下拉框,然后再定位下拉框的具体元素
from selenium import webdriver
import  os
import  time

driver = webdriver.Firefox()
file_path = 'file:///'+os.path.abspath('drop_down.html')
driver.get(file_path)

#首先定位到下拉框
drop_down = driver.find_element_by_id('ShippingMethod')

# 再点击下拉框到的选项
drop_down.find_element_by_xpath('//option[@value='10.69']').click()
time.sleep(5)
driver.quit()

 

============================================

drop_down.html源码

<html>
<body>
<select >USPS First Class ==> $3.20</option>
</select>
</body>
</html>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-25
  • 2021-11-25
  • 2022-12-23
  • 2021-12-09
猜你喜欢
  • 2021-06-04
  • 2021-06-10
  • 2021-06-07
  • 2022-12-23
  • 2022-12-23
  • 2021-11-09
  • 2019-08-01
相关资源
相似解决方案