【发布时间】:2020-05-13 13:07:33
【问题描述】:
如何从日历中选择日期?
网站中有日历。选择日期的方法是单击任意日期并将鼠标指针拖动到所需日期,然后松开鼠标单击。
尝试了 ActionClass 但没有成功?
谁能帮帮我?
【问题讨论】:
-
分享详情。错误,您的日历的 DOM 和您尝试过的代码 sn-p。
-
@Test public void selectDate() throws InterruptedException { System.setProperty("webdriver.chrome.driver", "C:\\Users\\A740493\\webautomation\\webauto\\src\\主\\资源\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.get("automationintesting.online/#/"); Thread.sleep(2000);
-
driver.findElement(By.xpath("//button[@id='next']")).click(); driver.findElement(By.xpath("//button[@id='next']")).click(); driver.findElement(By.xpath("//button[@id='next']")).click(); driver.findElement(By.xpath("//button[@id='next']")).click(); driver.findElement(By.xpath("//button[@id='closeModal']")).click();线程.sleep(5); driver.findElement(By.xpath("//button[text()= '预订这个房间']")).click(); System.out.println("点击按钮");
-
Thread.sleep(5); WebElement calendar = driver.findElement(By.xpath("//div[@class='rbc-month-row'][4]"));动作动作 = 新动作(驱动程序); act.dragAndDropBy(日历,628,1242).release().build().perform();日历.click();
-
以上是我创建的全部代码。该代码包含应用程序 URL:automationintesting.online/# 我没有收到任何错误。测试用例成功通过。但这是一个错误的通行证
标签: selenium automation datepicker webautomation