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