the positioning element selenium non-select drop-down box, positioned less than

First look at the effect the page: is a drop-down list that can be entered

 

 

 Look at the code: drop-down box is li and ul analog, not select the type, it is not traditional select the positioning method

 

 

1 idea : Since it is entered, it can be used as input box to enter on the line

    1, positioning input box

    2. Click the input box

    3, data entry drop-down options

   Click on the input box can be found, when prompted to enter after performing the positioning element is less than

 

Ideas 2 : Navigate to each element of a drop-down options, click operation

    1, positioning input box

    2. Click the input box

    3, positioning elements

    4, click on the element

    When executing the third step, select the copy xpath in the code at the right page, I chose the "1 baby products", xpath: // * [@ id = "6d0a7eac-4293-409b-f5ae-c862f3380a5d"] / ul / li [2], is performed using this error xpath

    Just as I was about to give up in dire straits, and Baidu to a post that is the id xpath can be replaced , and then tried, xpath:   // * [@ class = "Ant-the SELECT-the DropDown-the MENU-Item" ] [1], the implementation of it, a success! ! !

 

code show as below:

 

 

Summary: The idea did not try to replace the id xpath css 1, may also be successful.

        2. The method of thinking is right, wrong in too credulous page features a built-in copy xpath path right, but has no basis to this element, the next encounter the same problem, switch positioning method

 

    

 

Guess you like

Origin www.cnblogs.com/caoyinshan/p/11317116.html