Python组合框,用于选择日历月

Python组合框,用于选择日历月,python,selenium,pycharm,Python,Selenium,Pycharm,我在与日历对应的布局中有一个组合框。我想对照日历上显示的月份(以MM/YYYY格式显示)检查用户选择的月份。如果两者不相等,我希望导航到日历上的前一个月,再次检查,然后重复,直到满足条件 如何检查用户选择的月份是否包含在日历中 下面是从日历标题中提取的代码: nodeCssSelector:".calendar-header" 以下是日历上显示“2020年2月”的文本中的代码: Name: "February 2020" nodeCssSelector:"strong.ng-binding#t

我在与日历对应的布局中有一个组合框。我想对照日历上显示的月份(以MM/YYYY格式显示)检查用户选择的月份。如果两者不相等,我希望导航到日历上的前一个月,再次检查,然后重复,直到满足条件

如何检查用户选择的月份是否包含在日历中

下面是从日历标题中提取的代码:

nodeCssSelector:".calendar-header"
以下是日历上显示“2020年2月”的文本中的代码:

Name: "February 2020"
nodeCssSelector:"strong.ng-binding#text"
class:"calendar-header col-xs-8"
以下是我尝试过的代码:

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
使用提供的答案,以下代码对我有效:

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

什么是sg?我们需要更多的上下文。@AMC
sg
PySimpleGUI
。我编辑了原始代码以反映这一点。