As shown, a progress bar control may appear on some Web pages, and the control's structure code is first clarified when it is processed, such as:
The control here consists of three parts: a progress bar, a slider, and an input box. The input box has been introduced before, no longer tells
The progress bar can get the current value through the Title property
Specific operation can be achieved through the actionchains in the Move_by_offset to achieve the movement of the slider, the specific code is as follows
From selenium.webdriver.common.action_chains import Actionchains #导入ActionChains模块
Browser = Webdriver. Firefox ()
Browser.get (URL) #url为目标WEB的链接
brightnessline=browser.find_element_by_id ("Sliderbrightness_line") #通过ID定位到进度条
Brightnessline.get_attribute ("title") #通过title属性获取当前的值
brightnessslider=browser.find_element_by_id ("Sliderbrightness_thumb") #通过ID定位到滑动块
Actionchains (browser). Click_and_hold (Brightnessslider). Move_by_offset ( -6,7). Release (). Perform () #通过move_by_ Offset () Move slider, 6 means move left 6 pixels in the horizontal direction, 7 means move upward 7 pixels vertically
Python+selenium+eclipse performing web automation (v) Special controls--progress bar