0

I have a combo box within a layout that corresponds to a calendar. I want to check the month the user selects against the month displayed on the calendar (displayed in MM/YYYY format). If the two are not equal, I want to navigate to the previous month on the calendar, check again, and repeat until the condition is met.

How can I check to see if the month selected by the user is contained within the calendar?

Here's code pulled from the calendar header:

nodeCssSelector:".calendar-header"

Here's code from the text displaying "February 2020" on the calendar:

Name: "February 2020"
nodeCssSelector:"strong.ng-binding#text"
class:"calendar-header col-xs-8"

Here's the code I've tried:

import time
import PySimpleGUI as sg
import self
from selenium import webdriver
from time import strftime
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.remote.webelement import WebElement

layout = [[sg.Text('Email')],
          {sg.Input()},
          [sg.Text('Password')],
          [sg.Input()],
          [sg.Text('Select Month')],
          [sg.Combo(['January', 'February', 'March', 'April', 'May', 'June', 'July',
                     'August', 'September', 'November', 'December'], size=(10, 1))],
          [sg.OK(), sg.Cancel()]]

window = sg.Window('Data Collector', layout)
event, values = window.read()
stu = (values[2])
mo = (values[3])
window.close()

date = browser.find_element_by_css_selector('calendar-header col-xs-8')

while True:
    if mo != str(date):
        browser.find_element_by_css_selector('.nav-left > button:nth-child(1)').click()
    else:
        continue
Alex Elfont
  • 115
  • 1
  • 12

1 Answers1

0

Using the answer provided here, the following code worked for me:

if mo in browser.page_source:
    browser.find_element_by_css_selector('.nav-left > button:nth-child(1)').click()
else:
    continue
Alex Elfont
  • 115
  • 1
  • 12