简体   繁体   English

如何使用 selenium 和 Python 从日历中获取 select 日期、月份和年份

[英]How to select date , Month , and year from a calendar using selenium with Python

How to select date, Month and year from a calendar using selenium with Python without Hardcoding如何使用 selenium 和 Python 从日历中获取 select 日期、月份和年份,而无需硬编码

    import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;

public class fbcalender {

    static WebDriver driver;

    public static void main(String[] args) throws Exception {
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\User\\Downloads\\chromedriver83\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        driver.manage().window().maximize();
     //Here you can give dates as parameters
        setday(driver,"12","Aug","1999");


    }

    public static void setday(WebDriver driver,String day,String month,String year)
    {
        // Select date
        Select dates=new Select(driver.findElement(By.id("day")));
        dates.selectByValue(day);

        //select month from drop down
        Select Months=new Select(driver.findElement(By.id("month")));
        Months.selectByVisibleText(month);

        //select year
        Select Years=new Select(driver.findElement(By.id("year")));
        Years.selectByVisibleText(year);


    }



}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从日期获取月份和年份 - How to get month and year from date 如何在 python 中获取带有年份和月份的月份的第一个和最后一个日期 - How to get the first and last date of the month with Year and Month in python 如何使用 Selenium 和 Python 更改日历中的日期? - How to change date in the calendar with Selenium and Python? 如何在 Python3 Pandas 中选择每个月的最大日期 - How to select maximum date from each month in Python3 Pandas 从 Python 中的 1 个日期生成当前日历年月和未来日历年月 - Generate current calendar year months and future calendar year months from 1 date in Python 从 utc 格式字符串 python 中提取 Date-Month_year - Extract Date-Month_year from utc format string python 如何使用日期、月份和年份填充数据框并操作该数据框? - How to populate a dataframe using Date, Month and Year and manipulate that dataframe? 使用 Selenium Webdriver Python 从表中获取链接、月份和日期,但获取 web 元素没有属性 len() - Fetching links, month and date from a table using Selenium Webdriver Python but getting web element has no attribute len() 检查日期是否属于python中的给定月份和年份 - Check if a date belongs to a given month and year in python 如何比较 python 中的日期? 我有月份日期年份格式并想与当前日期(7 天内)进行比较 - How to compare date in python? I have a month date year format and want to compare to the current date (within 7 days)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM