从Python中的DatePicker中选择 [英] Select from a DatePicker in Python

查看:324
本文介绍了从Python中的DatePicker中选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以通过Selenium网络驱动程序(在Python中)代码帮助我,以便在上述链接的输入日期中自动选择一个日期.

Can anyone help me with the Selenium webdriver (in Python) code to automatically select a date in the input date in the above link.

https://www.nseindia.com/products/content/derivatives/equities/archieve_fo.htm

这只是一行代码,但是我浪费了很多时间.有人请帮忙.我已经尝试过.send_keys()函数,并搜索了数小时的有关datepicker的问题.请帮助.

It is just one line of code but I've wasted hours behind it. someone please kindly help. I've tried the .send_keys() function and have searched for hours about the datepicker issue. Kindly help.

推荐答案

在自动发送<input>标记中的日期时,您还没有提到卡住的确切位置. <input>标记的 type 作为 text 的方式以及以下代码块的工作方式是完美的:

You havn't mentioned exactly where you are stuck while automatically sending a date in the <input> tag. How ever the <input> tag is having type as text and the following code block works perfect :

  • 代码块:

  • Code Block :

from selenium import webdriver

driver=webdriver.Firefox(executable_path=r'C:\path\to\geckodriver.exe')
driver.get("https://www.nseindia.com/products/content/derivatives/equities/archieve_fo.htm")
print("Page Title is : %s" %driver.title)
driver.find_element_by_xpath("//input[@class='textboxdata hasDatepicker' and @id='date']").send_keys("10-04-2018")

  • 控制台输出:

  • Console Output :

    Page Title is : NSE - National Stock Exchange of India Ltd.
    

  • 快照:

  • Snapshot :

    这篇关于从Python中的DatePicker中选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆