我怎样才能获得selenium IDE中的日期和时间

时间:2021-01-15 16:03:30

I'm using selenium IDE and i would like to capture only the date and time from a field that was updated

我正在使用selenium IDE,我想只从已更新的字段中捕获日期和时间

Example:

Updated by James in 07/05/2015 - 09:50

James于2015年7月5日 - 09:50更新

I need to get only this date and the time from the record updated

我需要只更新这个日期和记录更新的时间

Is there a way to do this ?

有没有办法做到这一点 ?

Thanks

1 个解决方案

#1


Well you can do it with storeEval(). You can use JavaScript to manipulate stored variables. Lets assume that you stored that whole text in variable updated

那么你可以使用storeEval()来做到这一点。您可以使用JavaScript来操作存储的变量。让我们假设您将整个文本存储在变量更新中

${updated} == "Updated by James in 07/05/2015 - 09:50"

Now we just need to get that variable and get part of its text:

现在我们只需要获取该变量并获取其部分文本:

Command: storeEval()
Target:  storedVars['updated'].split(' ')[4]
Value:   date

Basically we get updated and we split it into array using space as separator, and then we get 4th element of array, which contains date and store in it new variable date.

基本上我们得到更新,我们使用空格作为分隔符将其拆分为数组,然后我们得到数组的第4个元素,其中包含日期并在其中存储新的变量日期。

Now:

${date} == "07/05/2015"

The same you can do with time.

你可以用时间做同样的事情。

#1


Well you can do it with storeEval(). You can use JavaScript to manipulate stored variables. Lets assume that you stored that whole text in variable updated

那么你可以使用storeEval()来做到这一点。您可以使用JavaScript来操作存储的变量。让我们假设您将整个文本存储在变量更新中

${updated} == "Updated by James in 07/05/2015 - 09:50"

Now we just need to get that variable and get part of its text:

现在我们只需要获取该变量并获取其部分文本:

Command: storeEval()
Target:  storedVars['updated'].split(' ')[4]
Value:   date

Basically we get updated and we split it into array using space as separator, and then we get 4th element of array, which contains date and store in it new variable date.

基本上我们得到更新,我们使用空格作为分隔符将其拆分为数组,然后我们得到数组的第4个元素,其中包含日期并在其中存储新的变量日期。

Now:

${date} == "07/05/2015"

The same you can do with time.

你可以用时间做同样的事情。