我想从 iframe 内的日历弹出窗口中单击日期。我在下面写了抛出无法找到元素错误的硒代码。请帮助我编写正确的 xpath 或 selenium 代码。我是 Selenium 的新手
硒代码:
WebElement iframe =driver.findElement(By.id("NewsSearchDateToInput_selector_iframe"));
driver.switchTo().frame(iframe);
//clicking on date 3
driver.findElement(By.xpath("//div[3][@class='daysNumbersStyles']")).click();
错误:无法定位元素“//div[3][@class='daysNumbersStyles']”
html标签:
<iframe id="NewsSearchDateToInput_selector_iframe"
class="dateTimeSelectorContainerStyle altFlexibleContainer"
src="javascript:false;"
style="left: 1216px; top: 245px; width: 249px; height: 207px;
display: block;"/>
<div class="dateTimeSelectorContainerStyle altFlexibleContainer"
style="top: 245px; left: 1216px; display: block;">
<div class="top">
<div class="content">
<div class="dateSelectorHeader">
<div class="dateSelectorBody">
<div class="yearMonthSelectorStyle">
<div id="NewsSearchDateToInput_selector_monthSelector" class="monthSelectorListStyle">
<div class="daysStyle">
<div>
<div class="daysNumbersDivStyle">
<div class="daysNumbersStyles">1</div>
<div class="daysNumbersStyles">2</div>
<div class="daysNumbersStyles">3</div>