Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python中的断言_Python_Selenium_Automation_Assert - Fatal编程技术网

python中的断言

python中的断言,python,selenium,automation,assert,Python,Selenium,Automation,Assert,我需要声明日期和时间戳 如何使用python selenium做到这一点 要求是,我填写表格并提交,一旦提交,它将成功提交,当我查看它时,它将显示一个名为“添加日期”的标签文本字段:并显示日期/时间。 现在在我的自动化中-我想断言这个日期/时间,以确保它不是空的(我想使用断言来验证它。对于不同的记录,这个日期/时间将不同) 作为参考,我附上了两个截图 请找到以下解决方案: driver = webdriver.Chrome(executable_path=r"chromedriver.exe")


我需要声明日期和时间戳

如何使用python selenium做到这一点 要求是,我填写表格并提交,一旦提交,它将成功提交,当我查看它时,它将显示一个名为“添加日期”的标签文本字段:并显示日期/时间。 现在在我的自动化中-我想断言这个日期/时间,以确保它不是空的(我想使用断言来验证它。对于不同的记录,这个日期/时间将不同) 作为参考,我附上了两个截图
请找到以下解决方案:

driver = webdriver.Chrome(executable_path=r"chromedriver.exe")
element=driver.find_element_by_xpath("//strong[@class='ng-binding ng-scope']")
print element.text

if(len(element.text) == 0): 
    print ("Yes") 
else : 
    print ("No")