当前位置: 首页 > news >正文

手机php网站开发工具江西网站建设找哪家

手机php网站开发工具,江西网站建设找哪家,企业如何建设网站,如何写软文赚钱几年前#xff0c;我正在忙于一些工作#xff0c;客户希望了解如何解决现实世界中的问题。 他们要求我自动化woot.com网站上的某些任务。 他们的任务是访问各个网站#xff0c;并阅读当天商品的名称和价格。 我写了一些Selenium代码#xff0c;以为可以将其张贴在这里我正在忙于一些工作客户希望了解如何解决现实世界中的问题。 他们要求我自动化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页面 public class WineWoot extends BaseWoot {/*** Constructor* param url pass in the url of the web site*/public WineWoot(String url) {super(url);}/*** Implementation of the method to get the price of the object for sale on* the Woot web site.*/public String getPrice(Selenium selenium) {//if you need to update the xpath to the piece of text of interest - use xpather firefox pluginString xPath //html/body/header/nav/ul/li[8]/section/div/a/div[3]/span;selenium.waitForCondition(selenium.isElementPresent(\xpath xPath \);, 12000);return selenium.getText(xPath) ;}/*** Implementation of the method to get the product name of the item for sale* on the Woot web site**/public String getProductName(Selenium selenium) {//if you need to update the xpath to the piece of text of interest - use xpather firefox pluginString xPath //html/body/header/nav/ul/li[8]/section/div/a/div[2];selenium.waitForCondition(selenium.isElementPresent(\xpath xPath \);, 12000);return selenium.getText(xPath) ;}} 注意–当时我使用了xPather插件–对于最新版本的firefox无效因此现在我使用firebug 。 然后我写了实际的“测试” package uk.co.doogle;import com.thoughtworks.selenium.*;import java.io.BufferedWriter;import java.io.FileWriter;import java.util.ArrayList;import java.util.List;/*** This class is where we define tests of the Woot web sites* author Tony**/public class TestWoots extends SeleneseTestCase {/*** Outputstream for our results file*/private BufferedWriter out;/*** Our list of Woot web sites we want to test*/private ListBaseWoot sites new ArrayListBaseWoot();/*** This is where we do any set up needed before our test(s) run.* Here we add the list of Woot web sites we want to test and we create an* output stream ready to write results to file*/public void setUp() throws Exception {sites.add(new BaseWoot(http://www.woot.com/));sites.add(new ShirtWoot(http://shirt.woot.com/));sites.add(new WineWoot(http://wine.woot.com/));try {//lets append to our file...FileWriter fstream new FileWriter(out.csv, true);out new BufferedWriter(fstream);out.write(Site, Product Name, Product Price);out.newLine();} catch (Exception e) {System.err.println(Error creating a file to write our results to: e.getMessage());}}/*** Tests getting the item name and price for the item for sale on each Woot web site we test. We see the results of the test* in std out in the form of a table and we also write the results to a csv file.* If there are any errors getting the information, this is displayed instead.** How to run me: open command prompt and from the directory where our selenium server is* located type: java -jar selenium-server-standalone-2.0b3.jar (or equivalent) and wait for the server to start up.* Then just run this unit test.*/public void testGetItemsAndPrices() throws Exception {//for each Woot site in our list of sites we want to testfor (BaseWoot woot : sites) {//lets put this in a try catch block as we want to try ALL the sites - some may be down or slow...try {selenium new DefaultSelenium(localhost, 4444, *firefox, woot.getUrl());selenium.start();selenium.open(/);selenium.waitForPageToLoad(50000);//add a new row for our table to std outSystem.out.println();//print out the information we need - the site, the title of the item for sale and the priceString siteUrl woot.getUrl();String productName woot.getProductName(selenium);String productPrice woot.getPrice(selenium);//sometimes there are commas which mess up our csv file - so//we substitute with ;productName productName.replace(,, ;);System.out.print(website: siteUrl );System.out.print(product name: productName);System.out.print(price: productPrice);out.write(siteUrl , productName , productPrice);out.newLine();} catch (Exception ex) {//here may may see that the web site under test has changed and the xpath to the price or product name may need to//be changed in the Woot classSystem.out.print(problem getting the data for: woot.getUrl() ex.getMessage() );} finally {selenium.stop();}}}/*** Any tear-down we need to do to cleanup after our test(s).* Here we just stop selenium and close the output stream*/public void tearDown() throws Exception {selenium.stop();out.close();}} 我知道这段代码已经使用了几年并且我做了一些小的改动以使其能够与当前的woot.com网站一起使用-我要做的就是为其获取最新的selenium-server-standalone.jar 。与最新的Firefox一起使用还可以将xpath更新为价格和产品名称信息。 这将是对代码的一个很好的改进-使它成为数据驱动的-这样我们就可以只更新配置文件中的xpath而无需更改我在这里使用的硬编码文件。 那实际上是来自客户的唯一反馈。 参考来自Doogle Ltd博客的JCG合作伙伴 Tony Dugay的Java Selenium / WebDriver示例 。 翻译自: https://www.javacodegeeks.com/2012/12/a-seleniumwebdriver-example-in-java.html
http://www.pierceye.com/news/151034/

相关文章:

  • 自己做网站app甘肃网站域名申请公司
  • 电子商务网站开发的课程介绍2023年新闻摘抄
  • 合肥如何做百度的网站推广百度知道官网首页登录入口
  • 织梦网站怎么做二级域名广州做网站费用
  • 湖南的商城网站建设网站建设与管理专业就业
  • 诸城企业网站建设wordpress经典编辑器插件
  • 做视频播放网站 赚钱全国建筑网站
  • 网站建站要多少钱2021安全员证报名入口
  • 成都建设网站那家好vs2019可以做网站吗
  • 个人网站开发教程济南高新网站制作
  • 中国空间站最新进展欧泰国际物流网站
  • 做淘宝链接网站成都网站建设 3e网络
  • 兰州中川国际机场t3航站楼vue单页面做网站加载慢
  • 公司网站制作费用申请泸州网站建设公司
  • 专业网络优化有名的seo外包公司
  • 宿迁网站建设制作湖南常德邮编
  • 网站制作方案电子商务网站建设与维护的主要内容
  • 网站淘宝客怎么做的建网站前途
  • 宁波网站开发服务网页制作技巧
  • 中医网站风格网络规划设计师2022论文5月
  • 网站主办者单位有效证件电子件是什么怎么做免费的产品网站
  • 设计素材网站好融资吗网站设计需要需要用
  • 北京品牌营销的服务机构sem和seo有什么区别
  • 注册企业网站上海人才中心档案托管
  • 建设银行的网站为什么登不上公司员工培训方案
  • 网站形式wordpress 顶部工具栏
  • 网站前后台修改wordpress用户密码
  • 微信 公司网站 怎么做手机端视频网站模板下载
  • 何为响应式网站太原自助建站
  • 网站建设方案书怎么写安徽和住房建设厅网站