当前位置:网站首页>Selenium basics controls the scroll bar of the browser
Selenium basics controls the scroll bar of the browser
2022-07-24 07:37:00 【everyone_ yi】
Selenium Provides a call to JS The power of code , have access to execute_script() Function execution JS Code to achieve the effect of moving the scroll bar .
# -*- coding: utf-8 -*-
from selenium import webdriver
import time
from selenium.webdriver.common.by import By
driver = webdriver.Edge()
driver.get("https://www.baidu.com")
# Inquire about golang
driver.find_element(by=By.ID,value="kw").send_keys("golang")
driver.find_element(by=By.ID,value="su").click()
time.sleep(2)
# Drag the page scroll bar to the bottom
js = "var q=document.documentElement.scrollTop=10000"
driver.execute_script(js)
time.sleep(3)
# Move the scroll bar to the top of the page
js_back = "var q=document.documentElement.scrollTop=0"
driver.execute_script(js_back)
time.sleep(3)
# driver.quit()
selenium+python Summary of the problem of sliding the page scroll bar to the end
边栏推荐
- UNI-APP_小程序或h5页面背景音乐的播放与暂停
- numpy.arange
- 觉维设计响应式布局
- [sklearn] data preprocessing
- [steering wheel] the super favorite idea efficiency artifact save actions is uninstalled
- 25. Message subscription and publishing - PubSub JS
- Buffer overflow vulnerability of network security module B in national vocational college skills competition
- Jersey2.25.1 integration freemaker
- Fopen, fwrite, fseek, fTell, FREAD use demo
- System integration project management engineer (soft test intermediate) key knowledge, recitation version
猜你喜欢

requests-爬虫实现一个简易网页采集器

FPGA realizes reading and writing of axi4 bus

Jenkins 详细部署

游戏三子棋

Li Kou, niuke.com - > linked list related topics (Article 1) (C language)

觉维设计响应式布局

Development system selection route

Advanced part of C language IV. detailed explanation of user-defined types

Injectfix principle learning (to realize the heat of repair addition)

JS_ Realize the separation of multiple lines of text into an array according to the newline
随机推荐
Requests crawler implements a simple web page collector
Feature Selective Anchor-Free Module for Single-Shot Object Detection
Win10 sound icon has no sound
Source code analysis of Nacos configuration center
25. Message subscription and publishing - PubSub JS
requests-爬取页面源码数据
Sword finger offer special assault edition day 8
Harbor2.2 quick check of user role permissions
FPGA realizes reading and writing of axi4 bus
[line test] Figure finding regular questions
[word] how to generate the index directory on the left
MySQL statement
Advanced part 5 of C language. Dynamic memory management
系统集成项目管理工程师(软考中级)重点知识、背诵版
InjectFix原理学习(实现修复加法的热更)
Advanced part of C language I. data storage
[steering wheel] the super favorite idea efficiency artifact save actions is uninstalled
Advanced part of C language IV. detailed explanation of user-defined types
【信息系统项目管理师】第七章 复盘成本管理知识架构
B. Also Try Minecraft