[英]I was trying to select the next month from the calendar and was unable to do so
This is the code which I was trying to execute. 这是我试图执行的代码。
driver.get("https://easemytrip.com/");
driver.findElement(By.id("ddate")).click();
driver.findElement(By.id("img2")).click();
I am unable to click on the next month of the calendar. 我无法点击日历的下个月。 Here is the HTML code.
这是HTML代码。
<div class="month"> <div id="dvprevious" class="dvnxt" runat="server"> <img id="img2" onclick="return FillcalendarV(03,2017);" alt="Arrow" src="img/left.png"/> </div> <div class="month2">Apr 2017</div> <div class="month3"> <img id="img1" onclick="return FillcalendarV(05,2017);" alt="Arrow" src="img/right.png"/> </div> </div>
My two work arounds were to force a mouse click on the item location. 我的两种解决方法是强迫鼠标单击项目位置。
WebElement elem = driver.findElement(By.id("id"));
Actions action = new Actions(driver);
action.moveToElement(elem).perform();
action.moveToElement(elem).click().perform();
or 要么
driver.findElement(By.id("id")).sendKeys(Keys.ENTER);
The problem is that it takes a second for the calendar popup to get rendered so you need a brief pause. 问题在于日历弹出窗口要花一秒钟的时间,因此您需要短暂的停顿。 The next problem I ran into is that you apparently can't click the > img because it's blocked by the container DIV.
我遇到的下一个问题是您显然无法单击> img,因为它已被容器DIV阻止。 So, I just clicked the container DIV and it worked.
因此,我只单击了容器DIV,它就起作用了。 The code below works.
下面的代码有效。
driver.get("https://easemytrip.com/");
driver.findElement(By.id("ddate")).click();
new WebDriverWait(driver, 3).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div.month3"))).click();
Following code will work. 以下代码将起作用。
WebElement ele1 = driver.findElement(By.id("dvfarecal"));
ele1.click();
WebDriverWait wait = new WebDriverWait(driver, 5);
WebElement ele2 = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//img[@src='img/right.png']")));
ele2.click();
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
WebElement date = driver.findElement(By.id("snd_3_10/05/2017"));
date.click();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.