【发布时间】:2020-05-05 01:04:45
【问题描述】:
我想选择一个选项,但我无法在下面找到给定 html 标记的正确 xpath,因为它不是选择标记。如何创建上述标签的动态 xpath?
<span class="select2-selection__rendered" id="select2-ContentPlaceHolder1_signup_CompanyType-container" role="textbox" aria-readonly="true"><span class="select2-selection__placeholder">Select an option</span></span>
<span class="select2-selection__rendered" id="select2-ContentPlaceHolder1_signup_CompanyType-container" role="textbox" aria-readonly="true" title="IT"><span class="select2-selection__clear" data-select2-id="11">×</span>IT</span>
driver.findElement(By.xpath("//span[@id='select2-ContentPlaceHolder1_signup_CompanyType-container']")).click();
【问题讨论】:
-
driver.findElement(By.xpath("//span[@id='select2-ContentPlaceHolder1_signup_CompanyType-container']")).click();
标签: java html selenium-webdriver