我刚接触硒。我正在尝试从RedBus.com选择开始日期,有人可以帮我这个忙。下面是我尝试过的代码。
public class RedBusSearch extends RedBusLibraries {
public RedBus red = null;
public WebDriver driver = null;
@Test public void travel() {
logger = extent.createTest("SpiceJet flight bookin");
red = new RedBus(driver);
delay(3000);
input(red.getSource(), "Hyderabad", "source");
input(red.getDestination(), "Bangalore", "Destination");
click(red.getOnwardDate(), "onwards date");
driver.findElement(By.xpath("//div[@id='rb-calendar_onward_cal']"));
List<WebElement> month = driver.findElements(By.xpath("//div[@class='rb-calendar']/table/tbody/tr/td"));
System.out.println(month.size());
for (WebElement ele : month)
{
if (ele.getText().equals("15"))
ele.findElement(By.linkText("15")).click();
break;
}
}
}
、、
答案 0 :(得分:0)
您必须单击下个月按钮,直到达到所需的月份。然后选择日期。这是选择15 May 2019
driver.findElement(By.cssSelector("[for='onward_cal']")).click();
//select month
while(!driver.findElement(By.cssSelector("#rb-calendar_onward_cal .monthTitle")).getText().equals("May 2019")) {
driver.findElement(By.cssSelector(".rb-calendar#rb-calendar_onward_cal .next button")).click();
System.out.println(driver.findElement(By.cssSelector("#rb-calendar_onward_cal .monthTitle")).getText());
Thread.sleep(1000);
}
//select date
driver.findElement(By.xpath("//div[@id='rb-calendar_onward_cal']//td[.='15']")).click();