Selenium2+python Automated 26-JS processing inline div scroll bars

Source: Internet
Author: User

Objective

There is a special use JS to solve the browser scroll bar problem, life is always colorful, some scroll bar on the page, this time also rely on JS eldest brother to solve.

One, inline scroll bar

1. Here's a picture of the inline div with a scroll bar, remembering its looks.

2. The page source code is as follows: (the usual: copy down, save it with text, suffix changed to. html, open with a browser)

<! DOCTYPE html>
<meta charset= "UTF-8" > <!--for HTML5
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<style type= "Text/css" >

Div.scroll
{
Background-color: #afafaf;
width:500px;
height:100px;
Overflow:auto;
}


</style>

<body>
<p> Personal Public Number:yoyoketang</p>
<p> This is an inline div scroll bar </p>
<div id= "Yoyoketang" name= "Yoyo" class= "scroll" > this is an inline div: During the Republic of China, nine families were guarding Changsha, known as the "nine-door prefect". These nine powerful, the outside eight row of no one knows, no one does not know, almost all funerary, outflow of Changsha inevitably pass through a family.
1933 Autumn, a mysterious ghost car slowly into the Changsha railway station, the first nine door "Zhang da Rookie" Zhang Qishan as an arm officer, was ordered to investigate the whole story. Zhang Qishan and eight ye Zittie mouth all the way to visit, found that there is a suspicious mining outside Changsha City, has been the Japanese snooping.
To solve the mystery of the mine, Zhang Qishan to help the same as nine doors on the divas of the drama of the February red, but February red, although the origin of archaeological family, but the heart of a seriously ill wife girl, has long been out of hand. Zhang Qishan for the National righteousness and brotherhood, go northward to Crescent Hotel for February Red love wife seek medicine. In Peiping, Zhang Qishan met the Crescent hotel of the big Miss Yin Crescent, and for the Yin Crescent even point three lights, scattered all the house. Yin Crescent Help Zhang Qishan and other people smooth return to Changsha, two people secretly born. February The red love Wife is terminally ill, after taking medicine not to improve, finally died.
February Red Sadness but unexpectedly found that the family grandparents and mine also have a major connection, so cheer up spirit, decided to join hands with Zhang Qishan, Unlocking the mysteries of the mine zhegedancihenchanghenchangchangchangchangchanchanchanchangchangchangchancg</div>

</body>

Second, longitudinal rolling

1. This is the div attribute: <div id= "Yoyoketang" name= "Yoyo" class= "scroll" >

2. The simplest way to navigate through the ID is to control the scrollbar height by controlling the value of the scrolltop.

3. Run the following code to see if the page scrolls to the bottom, and then back to the top in five seconds. (Get inside address is the browser to open the address of the page)

Three, horizontal rolling

1. Position by ID First, control the scrollbar height by controlling the value of the ScrollLeft

Four, using the class attribute to locate

1.js is positioned with the class property and returns a list object, where the first one is available.

2. It is important to note that there are many small partners in element and elements that are not clear.


Sometimes many element properties are the same time, you can use the plural to locate, take the corresponding number of the first can be

In the learning process has encountered doubts, can add selenium (Python+java) QQ Group Exchange: 232607095

Selenium2+python Automated 26-JS processing inline div scroll bars

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.