Python+selenium+eclipse performing web automation (iii) browser frame and element positioning

Source: Internet
Author: User
Tags xpath

To locate the frame and element on the Web page, you need to understand the HTML structure of the page, as shown in:

In Firefox or IE, press the F12 button to invoke the Developer tool, in the HTML interface you can see the general structure of the page (also refer to http://wenku.baidu.com/view/f7f7514e763231126edb117a.html?). Re=view Learn more HTML content). The first is the HTML bottom, then the head file and the body body file. In this interface, you can use the arrow graphic buttons to quickly get the corresponding information for a control, such as the name of the frame, the name of the control, the ID, and so on.

When you perform Web Automation with Selenium 2.0 webdriver, there are often problems with clicking on a control's interface, or pop-up windows, where you need to use Webdriver's switch_to_frame for control operations on a new page or popup window ( Targetframename) statements are reloaded into a new interface or pop-up window.

In Firefox, for example, using the Firebug and Firepath two tools provided by Mozilla Firefox for quick page element positioning, F12 can be called Firebug after installation in the Firefox browser interface, while Firepath is integrated in Firebug. Such as:

In the upper right corner of the search bar input iframe keyword can search the current page frame information, the required page frame information extracted as Targetframename input into the above Switch_to_frame statement, you can achieve the jump between frame, Load.

Control information can be quickly obtained using Arrow graphics (the name of the frame, the name of the control, the ID, and so on), and because some developers have different development features that cause some of the controls to have no key information such as name or ID, you can use the Firepath tool to get the XPath for the control. Click the Firepath button to enter the Firepath interface, click the arrow button and then click the control you want to locate, and the XPath display box will get the XPath information for the control.

Use the Find_element_by_xpath (XPath) statement in a script to navigate to the control and perform the desired action

Python+selenium+eclipse performing web automation (iii) browser frame and element positioning

Related Article

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.