Dynamic dates in Selenium IDE
来源:互联网 发布:c语言黑客代码大全 编辑:程序博客网 时间:2024/06/06 10:41
http://dubbelfnutt.wordpress.com/2011/02/18/dynamic-dates-in-selenium-ide/
If you have a test where you need to input a date somewhere, chances are that you want a date sometime in the future. You don’t want to update your test everytime so you want the date to be dynamic. This can be achieved using javascript. In the following example, I use three selenese commands to do this. You can use just one command, but I want to make it simple to understand.
1) Stores a variable with the number of months into the future that I want my date to be. In this case 4 months. If I put this in a separate variable it will be much easier to change at a later time, rather than searching and replacing in the javascript below.
Command: store
Target: 4
Value: monthsToAdd
2) Formats and stores the date we want to use. Format in this example is Swedish, like so: “2011-02-18“.
Command: store
Target: javascript{var dates = new Date();var day = dates.getDate();if (day < 10){day = ‘0’ + day;} month = dates.getMonth() + 1 + parseInt(storedVars['monthsToAdd']);var year = dates.getFullYear();if (month > 12){month = month – 12;year = year + 1;}if (month < 10){month = ‘0’ + month;}year + ‘-‘ + month + ‘-‘ + day}
Value: dynamicDate
3) Types our dynamic date into a textbox, whos id contains “dateInputBox”.
Command: type
Target: //input[contains(@id, 'dateInputBox')]
Value: ${dynamicDate}
You can read more about javascripts and Selenium here. If you feel that I am wrong or you have something to add, please comment.
- Dynamic dates in Selenium IDE
- Dates in PHP and MySQL
- Time and Dates in DB2
- Dates in PHP and MySQL
- Selenium IDE
- selenium IDE
- Selenium IDE
- selenium ide
- Selenium IDE
- Selenium IDE
- Selenium IDE
- Selenium IDE
- 【Selenium】PARTI selenium IDE
- selenium + selenium IDE +firefox
- Dates
- selenium IDE+selenium RC+Firefox
- Selenium IDE简介
- Selenium IDE 基础
- 第一篇—开端
- C# Slugify方法
- C# URL操作
- .htaccess实现301网页永久重定向及302临时重定向
- URL重写:RewriteCond指令与RewriteRule 指令格式
- Dynamic dates in Selenium IDE
- Apache 中文乱码问题解决方法
- 解决用 entity_translation 模块建立多语言网站,在 Views 无法翻译问题
- BSCMAKE: error BK1506 : : No such file or directory 的解决
- 解决C++ 无法从void 转换为LRESULT的方法详解
- (面试)C语言指针程序改错题
- 怎样使用JS代码代码跳转的方法
- DirectX 9.0c游戏开发手记之RPG编程自学日志之15: Drawing with DirectX Graphics (用DirectX图形绘图)(第8-9节)
- LeetCode-Maximum Product Subarray