Find CURRENTLY selected

后端 未结 4 1121
醉话见心
醉话见心 2021-01-04 06:42

What\'s the correct XPath syntax to check if an option element is currently selected, or just to get the selected option

4条回答
  •  孤城傲影
    2021-01-04 07:11

    The problem could be the " (double quotes).

    //select/option[@selected='selected'] - Will match the selected option, i am using this successfully.

    //select/option[@selected='selected' and @value='specific value'] - Will only match the selected option if it has a 'specific value', i'm also using this.

    If you are still having trouble, it could be an entirely different problem, perhaps there is no option node. I hope this helps.

提交回复
热议问题