selenium C#下的zencart自动化测试(WFloginUrlPayment)环境4.0
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的更多相关文章
- 转载 基于Selenium WebDriver的Web应用自动化测试
转载原地址: https://www.ibm.com/developerworks/cn/web/1306_chenlei_webdriver/ 对于 Web 应用,软件测试人员在日常的测试工作中, ...
- 手机自动化测试:搭建appium手机自动化测试开发环境
手机自动化测试:搭建appium手机自动化测试开发环境 poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣,请大 ...
- selenium从入门到应用 - 1,环境准备(Java+TestNG+Maven+Selenium)
本系列所有代码 https://github.com/zhangting85/simpleWebtest 本文将介绍一个Java+TestNG+Maven+Selenium的web自动化测试脚本环境的 ...
- APP自动化测试的环境配置
什么是Appium? 第三方自动化框架(工具),扩充了selenium webdriver 协议,在原有的基础上添加了移动端测试API selenium webdriver 指定了客户端到服务端的协议 ...
- 移动端自动化测试Appium环境搭建(part1-2-3)
Appium移动端自动化测试相信大家都不陌生,appium的铁哥们是selenium,不管是selenium还是appium,都是调用webdriver来做自动化测试.今天关于appium的介绍我们不 ...
- 自动化测试平台环境docker部署
参考资料:testin云测 https://www.testin.cn接口自动化测试平台:http://120.79.232.23星云测试 http://www.threadingtest.com腾讯 ...
- Android自动化测试-UiAutomator2环境搭建
Android自动化测试-UiAutomator环境搭建(QQ交流群:490451176) 一.环境准备 1. 安装android sdk,并配置环境变量 2. 安装android studio,国内 ...
- linux下查看和添加PATH环境变量
linux下查看和添加PATH环境变量 $PATH:决定了shell将到哪些目录中寻找命令或程序,PATH的值是一系列目录,当您运行一个程序时,Linux在这些目录下进行搜寻编译链接. 编辑你的 PA ...
- Windows下搭建Spark+Hadoop开发环境
Windows下搭建Spark+Hadoop开发环境需要一些工具支持. 只需要确保您的电脑已装好Java环境,那么就可以开始了. 一. 准备工作 1. 下载Hadoop2.7.1版本(写Spark和H ...
随机推荐
- web.xml Attribute "xmlns" was already specified for element "web-app"
报错信息:Attribute "xmlns" was already specified for element "web-app" 由于项目的重命名,出现了x ...
- 定时帧:NSTimer和CADisplayLink
学习参考了:http://www.jianshu.com/p/c35a81c3b9ebhttps://zsisme.gitbooks.io/ios-/content/chapter11/frame-t ...
- CVE-2015-0057 POC构造 & 利用分析(2015.7)
CVE-2015-0057 POC构造 & 利用分析 主要内容: 构造POC 利用思路 0x00 初探 从这篇文章可以获知: 1.问题出在 win32k!xxxEnableWndSBArrow ...
- ionic的弹出框$ionicPopover
在ionic.html中 在controller.js中
- spring的校验框架 @Validated & BindingResult
controller上写法类似这样: @RequestMapping(value = "saleInfoList.json", method = RequestMethod.GET ...
- mac下配置gdb调试golang
mac下配置gdb调试golang 原文链接 https://sourceware.org/gdb/wiki/BuildingOnDarwin Building GDB for Darwin Crea ...
- 【原创】对Java的synchronized关键字的学习
在Java中,每一个线程都有一个内部锁.当我们使用synchronized关键字时,就是利用这个内部锁来实现线程对某个对象的锁定控制. 那么,如果某个对象中有两个方法,方法一和方法二都使用了synch ...
- NewtonJson中转义的斜杠\和多余的引号处理
使用newtonjson序列化的json串正常的,但通过网络传输后,会再包装一层引号和对原有定义引号的转义,最后结果就变成这种数据: “\"{\\\"State\":fa ...
- 关于设置CFileDialog的默认路径
CFileDialog d_File(FRUE, NULL,NULL,NULL,szFilter,FromHandle(m_hWnd)); // 如果写了下面这句那么每次打开都是这个设置的默认路径 ...
- Linux下安装awstats日志统计分析
1. 下载安装 cd /data/software wget http://prdownloads.sourceforge.net/awstats/awstats-7.0-1.noarch.rpm 2 ...