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 ...
随机推荐
- 【Python之路】第九篇--Python基础之线程、进程和协程
进程与线程之间的关系 线程是属于进程的,线程运行在进程空间内,同一进程所产生的线程共享同一内存空间,当进程退出时该进程所产生的线程都会被强制退出并清除.线程可与属于同一进程的其它线程共享进程所拥有的全 ...
- WPF之DatePicker使其只能选择日期,不能输入日期
<DatePicker.Resources> <Style TargetType="DatePickerTextBox"> <S ...
- python学习之批量更改文件格式
文件操作 import os, glob from PIL import Image path = 'D:/SBSR/view_1' imgslist = glob.glob(path+'/*.jpg ...
- EditText文本中用正则匹配是否包含数字,及判断文本只能是纯汉字或纯字母
遇到判断EditText中文本,是否为制定格式 EditText et; Button btn; @Override protected void onCreate(Bundle savedInsta ...
- Python基础篇-day6
本节简介: 1.模块1.1 时间模块1.2 random模块1.3 shutil模块1.4 shelve模块1.5 XML模块1.6 ConfigParser模块1.7 hashlib模块1.8 lo ...
- Calendar时间类型数据设置
Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, -1); calendar.set(Calendar.H ...
- SQLSERVER异机备份
/* 作者:landv 功能:异机备份 开发时间:2016年7月2日 15:27:08 */ ) drop procedure [dbo].[p_backupdb] GO create proc p_ ...
- 大数据时代之hadoop(四):hadoop 分布式文件系统(HDFS)
分布式文件系统即是网络中多台计算机组合在一起提供一个统一存储及管理的系统. Hadoop提供了一个文件系统接口和多个分布式文件系统实现,其中比较重要的就是HDFS(Hadoop Distributed ...
- MVC运行机制
一,第一次程序运行时 1,第一次请求的时候 会获取配置文件,然后有个应用启动事件到global.asax.2,在Global.asax文件中,网站第一次运行会创建RouteTable对象,实现URL到 ...
- UVa 12100 Printer Queue (习题 5-7)
传送门:https://uva.onlinejudge.org/external/121/12100.pdf 题意:队列中待打印的任务(1 <= n <= 100)带有优先级(1-9), ...