Java中的Selenium / WebDriver示例

几年前,我正在忙于一些工作,客户希望了解如何解决现实世界中的问题。 他们要求我自动化woot.com网站上的某些任务。

他们的任务是访问各个网站,并阅读当天商品的名称和价格。

我写了一些Selenium代码,以为可以将其张贴在这里,以防任何对任何人有用。

我得到了这份工作,所以这不会太糟糕。

首先,我定义了一个界面来表示一个woot页面:

package uk.co.doogle;

import com.thoughtworks.selenium.Selenium;

/**

* This interface defines the methods we must implement for classes

* of type Woot. Woot web sites have one item for sale every 24 hours.

* @author Tony

*/

public interface Woot {

/**

* Defines the interface of the method we use to get the price

* of the item for sale on a Woot website

* @param selenium the selenium object we pass in which is used to interact

* with the browser/web page

* @return String representation of the price of the item for sale

*/

public String getPrice(Selenium selenium);

/**

* Defines the interface of the method we use to get the product name

* of the item for sale on a Woot website

* @param selenium the selenium object we pass in which is used to interact

* with the browser/web page

* @return String representation of the product name of the item for sale

*/

public String getProductName(Selenium selenium);

}

然后,我多次实现了此接口,以表示各种woot页面的实际行为–例如,如果是winewoot页面:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值