select操作: from selenium.webdriver.support.select import Select select = Select() select.select_by_index(传入一个webelement的值) #就是一个find_element(By.xx,"")的返回值 select.select_by_value() select.select_by_visible_text()
js:滑动到对应的元素位置
ele = driver.find_element(By.XPATH,"")
driver.execute_script('argument[0].scrollIntoView(false);',ele) # scroll Into View
滑动到页面底部
driver.execute_script("window.scrollTo(0,document.body.scrollHeight)")
滑动到页面顶部
driver.execute_script("window.scrollTo(document.body.scrollHeight,0)")
通过js修改输入框的值
js="""
var a = document.getElementById("输入框的id");
a.readOnly=false;
a.vaule="修改后的值";
"""
driver.execute_script(js)
上述如果需要修改的值没有id属性,可以通过xpath寻找,如:
js="""
var a = argument[0];
a.readOnly=false;
a.vaule="修改后的值";
"""
ele = driver.find_element(By.XPATH, "你要找的xpath路径")
driver.execute_script(js,ele)