using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;//引用命名空间

namespace WFloginUrl
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnSubmit_Click(object sender, EventArgs e)//按提交按钮
{
IWebDriver driver = new FirefoxDriver();
//IWebDriver driver = new ChromeDriver();
INavigation navigation = driver.Navigate();
navigation.GoToUrl(txtURL.Text + "/login.html");
//System.Threading.Thread.Sleep(5000);
driver.FindElement(By.Id("gender-male")).Click();
driver.FindElement(By.Id("firstname")).SendKeys("1859@qq.com");
driver.FindElement(By.Id("lastname")).SendKeys("1859@qq.com");
driver.FindElement(By.Id("street-address")).SendKeys("1859@qq.com");
driver.FindElement(By.Id("suburb")).SendKeys("1859@qq.com");
driver.FindElement(By.Id("city")).SendKeys("1859@qq.com");
driver.FindElement(By.Id("state")).SendKeys("1859@qq.com");
driver.FindElement(By.Id("postcode")).SendKeys("1859@qq.com");
driver.FindElement(By.Id("telephone")).SendKeys("1859@qq.com");
Random ran = new Random();
int RandKey = ran.Next(1,1999);
driver.FindElement(By.Id("email-address")).SendKeys("1859" + RandKey + "@qq.com");
IWebElement passwordnew = driver.FindElement(By.Id("password-new"));
passwordnew.SendKeys("1859@qq.com");
driver.FindElement(By.Id("password-confirm")).SendKeys("1859@qq.com");
//IWebElement buttonRow = driver.FindElement(By.ClassName("buttonRow forward"));
passwordnew.Submit();
lblOutput.Text = "<font color=red>注册成功,购买产品 . . .</font>";//显示进程信息
System.Threading.Thread.Sleep(2000);

navigation.GoToUrl(txtURL.Text+"/index.php?main_page=product_info&products_id=12");

new SelectElement(driver.FindElement(By.Id("attrib-1"))).SelectByIndex(2);//SelectByText("(US):6.5=(UK):4.5=(EUR):37");

driver.FindElement(By.XPath("//div[@id='cartAdd']/input[5]")).Click();
lblOutput.Text = "加入购物车成功,运费 . . .";
//cartAdd.Click();
driver.FindElement(By.XPath("//div[@class='buttonRow forward']//a/img")).Click();
//btnForward.Click();
//System.Threading.Thread.Sleep(2000);
driver.FindElement(By.XPath("//div[@class='buttonRow forward']/input")).Click();
lblOutput.Text = "付款 . . .";
//btnForward2.Click();
//driver.FindElement(By.CssSelector("div.buttonRow.forward > input[type=\"image\"]")).Click();
//driver.FindElement(By.CssSelector("#cartAdd > input[type=\"image\"]")).Click();
// ERROR: Caught exception [ERROR: Unsupported command [selectWindow | null | ]]
// ERROR: Caught exception [Error: locator strategy either id or name must be specified explicitly.]
// ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=toolbox-panel-iframe-inspector | ]]
// ERROR: Caught exception [Error: locator strategy either id or name must be specified explicitly.]
new SelectElement(driver.FindElement(By.Id("Fristonecc-expires-month"))).SelectByText("02");
new SelectElement(driver.FindElement(By.Id("Fristonecc-expires-year"))).SelectByText("2016");
driver.FindElement(By.Id("Fristonecc-cardNo")).Clear();
driver.FindElement(By.Id("Fristonecc-cardNo")).SendKeys("4111111111111111");
driver.FindElement(By.Id("Fristonecc-cvv")).Clear();
driver.FindElement(By.Id("Fristonecc-cvv")).SendKeys("111");
driver.FindElement(By.Name("submitbtn")).Click();
System.Threading.Thread.Sleep(30000);
driver.Quit();

}
private void Form1_Load(object sender, EventArgs e)
{
txtURL.Text = "http://www.XXX.com";//文本框输入要测试的网址
}

}
}

selenium C#下的zencart自动化测试(WFloginUrlPayment)环境4.0的更多相关文章

  1. 转载 基于Selenium WebDriver的Web应用自动化测试

    转载原地址:  https://www.ibm.com/developerworks/cn/web/1306_chenlei_webdriver/ 对于 Web 应用,软件测试人员在日常的测试工作中, ...

  2. 手机自动化测试:搭建appium手机自动化测试开发环境

    手机自动化测试:搭建appium手机自动化测试开发环境   poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣,请大 ...

  3. selenium从入门到应用 - 1,环境准备(Java+TestNG+Maven+Selenium)

    本系列所有代码 https://github.com/zhangting85/simpleWebtest 本文将介绍一个Java+TestNG+Maven+Selenium的web自动化测试脚本环境的 ...

  4. APP自动化测试的环境配置

    什么是Appium? 第三方自动化框架(工具),扩充了selenium webdriver 协议,在原有的基础上添加了移动端测试API selenium webdriver 指定了客户端到服务端的协议 ...

  5. 移动端自动化测试Appium环境搭建(part1-2-3)

    Appium移动端自动化测试相信大家都不陌生,appium的铁哥们是selenium,不管是selenium还是appium,都是调用webdriver来做自动化测试.今天关于appium的介绍我们不 ...

  6. 自动化测试平台环境docker部署

    参考资料:testin云测 https://www.testin.cn接口自动化测试平台:http://120.79.232.23星云测试 http://www.threadingtest.com腾讯 ...

  7. Android自动化测试-UiAutomator2环境搭建

    Android自动化测试-UiAutomator环境搭建(QQ交流群:490451176) 一.环境准备 1. 安装android sdk,并配置环境变量 2. 安装android studio,国内 ...

  8. linux下查看和添加PATH环境变量

    linux下查看和添加PATH环境变量 $PATH:决定了shell将到哪些目录中寻找命令或程序,PATH的值是一系列目录,当您运行一个程序时,Linux在这些目录下进行搜寻编译链接. 编辑你的 PA ...

  9. Windows下搭建Spark+Hadoop开发环境

    Windows下搭建Spark+Hadoop开发环境需要一些工具支持. 只需要确保您的电脑已装好Java环境,那么就可以开始了. 一. 准备工作 1. 下载Hadoop2.7.1版本(写Spark和H ...

随机推荐

  1. python 学习 [day7]面向对象

    编程模式概念 面向过程:根据业务逻辑从上到下写垒代码 函数式:将某功能代码封装到函数中,日后便无需重复编写,仅调用函数即可 面向对象:对函数进行分类和封装,让开发“更快更好更强...” 面向对象的三大 ...

  2. java 枚举类型和数据二进制等问题思考

    .以下代码的输出结果是什么? int X=100; int Y=200; System.out.println("X+Y="+X+Y); System.out.println(X+ ...

  3. 五、oracle基本建表语句

    --创建用户create user han identified by han default tablespaceusers Temporary TABLESPACE Temp;grant conn ...

  4. Winform制作圆弧panel

    原理就是手动去画边框留出四个角 然后绘制四张圆弧的图片到panel上 public class ArcPanel : Panel { protected override void OnPaint(P ...

  5. react视频入门

    http://pan.baidu.com/s/1i46by8t     密码:48tt

  6. openstack私有云布署实践【15 创建租户网络+实例】

    这里以办公网测试环境为例,   (一)创建租户demo的网络   使用admin用户 source admin-openrc.sh 创建public公网 neutron net-create 1040 ...

  7. Java缓存框架

      JBossCache/TreeCache  JBossCache是一个复制的事务处理缓存,它允许你缓存企业级应用数据来更好的改善性能.缓存数据被自动复制,让你轻松进行Jboss服务器之间的集群工作 ...

  8. hdu 3986 Harry Potter and the Final Battle

    一个水题WA了60发,数组没开大,这OJ也不提示RE,光提示WA...... 思路:先求出最短路,如果删除的边不是最短路上的,那么对结果没有影响,要有影响,只能删除最短路上的边.所以枚举一下最短路上的 ...

  9. Jquery结合datagrid框架

    <head>     <meta http-equiv="Content-Type" content="text/html; charset=utf-8 ...

  10. POJ 2234 Matches Game(取火柴博弈1)

    传送门 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> ...