Selenium determining element types

Source: Internet
Author: User

In the Cascade drop-down box when you find the first time you select a drop-down box (such as a province), the second drop-down box may be an input box or a drop-down box, this time you need to determine the type of his element, to make judgments

Figure 1

Figure 2

The principle is simple: get the contents of the HTML file of the control and make a judgment after getting the content.

The HTML elements of Figure 1 are:

<input type= "text" name= "province" class= "Choicecountry inputtext long Js_choicestate" value= "" >

The HTML elements of Figure 2 are:

Practice:

Webelement Elem = driver.findelement (By.cssselector ("#addressfrom > Ul > Li:nth-child (7) > div > div"= Elem.getattribute ("InnerHTML"), #获取他的html文件 if (Province.contains ("select")) {Op.getselect ("Province"). Selectbyindex (1); // assign a value to a drop-down box Else {Op.loopsendkeysclean ("province", "Chengdu", 3,); Enter a value for the text file}

Selenium determining element types

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.