Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I was able to get helped by clicking on the first calendar and needed to do the same thing for the next calendar. SO i need to pick 1st day of the mon th on the first calendar nad for the 2nd calendar i need to click on the last day of next month. The schedule im creating is every two months.

THe first calendar pick is as follows and this works;

IWebElement FromCalendar = Chromedriver.FindElement(By.Id("ctl00_MainContent_dpStart_B-1")); //
        FromCalendar.Click();

        //Always Click the current 1st day of the month
        new WebDriverWait(Chromedriver, TimeSpan.FromSeconds(2)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//td[@class='dxeCalendarDay'][.='1']"))).Click();

The second calendar is the following and does not work, i also created a variable that is included in the xpath but i get a timeout error and even if i change the seconds to 20 or 30 seconds i still get the same error. If i hard coded the value in the variable it still wouldnt work.

String LastDayofNextMonth = endOfLastDayNextMonth.ToString("dd");

        // 2nd Calendar
        Chromedriver.FindElement(By.Id("ctl00_MainContent_dpEnd_B-1Img")).Click(); ; //

        //Click next month because schedule should be every 2 months

        Chromedriver.FindElement(By.Id("ctl00_MainContent_dpEnd_DDD_C_NMCImg")).Click(); //


        //Always Click the last day of next month - so schedule is for every 2 months

        new WebDriverWait(Chromedriver, TimeSpan.FromSeconds(3)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//td[@class='dxeCalendarDay'][.='"+LastDayofNextMonth+"']"))).Click();

The calendar does open and goes to the next month but the last day of the month is not clicked and i get the following error;

OpenQA.Selenium.WebDriverTimeoutException: 'Timed out after 3 seconds'

I am not sure why the first calendar works and the second doesnt.

Thank you in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
272 views
Welcome To Ask or Share your Answers For Others

1 Answer

I figured it out.

The Calendar had 2 day 30 therefore it was choosing the 30 of the month of October and should be the last day of next month which is Nov 30.

Final code;

new WebDriverWait(Chromedriver, TimeSpan.FromSeconds(5)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("(//td[@class='dxeCalendarDay'][.='"+LastDayofNextMonth+"'])[2]"))).Click();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...