Selenium move div inside the scroll bar, Action popup dialog box

Source: Internet
Author: User

Or use JS to move

The first thing to do is to locate this element

tend to use JS to locate elements, enter the following script, press ENTER, you can see the corresponding div block on the Debug page
$ ("div.table-responsive")

Scrolling method using ScrollLeft ()
$ ("div.table-responsive"). ScrollLeft (1000)

Apply to Java Selenium

To avoid entering numbers, you can write this

((Javascriptexecutor) driver). Executescript ("$ (\" Div.table-responsive\ "). ScrollLeft (Document.body.scrollWidth)" );

Second, the Action popup dialog box

Regular front-end dialogs are used in the form of div blocks

such as positioning <div class= "Mb_btnbox". ><span><span></div> the second span inside

$ ("Div.mb_btnbox"). Find ("Span:eq (1)")

((Javascriptexecutor) driver). Executescript ("$ (\" div.mb_btnbox\ "). Find (\" Span:eq (1) \ "). Click ()");

To skillfully use the functions of js,jquery, you will find that when using commonly used selenium functions are not able to locate elements, such as the element ID is similar to the change, can be based on the hierarchy of the structure of the movement of XPath operations

However, such as pop-up dialog box, I prefer to choose JS to operate the "OK", "Cancel" this, convenient and fast is not prone to error, but also improve the familiarity of js,jquery

Selenium move div inside the scroll bar, Action popup dialog box

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.