Selenium入门01

1、常用模块介绍

Selenium IDE 是一个FF插件,用于录制测试用例并重新运行。可以保持为html脚本,也可以导出为各种语言的单元测试
Selenium Html Runner 可以直接运行Selenium IDE导出的html脚本
Selenium Standalone Server 有三种运行模式(standalone、hub、node),后两种用于grid
Selenium Remote Control Selenium RC, Selenium1采用代理网站及JS注入的方式,达到操控网页的目的,在Selenium3已经取消支持
Browser Drivers Selenium2为在不修改网页的情况下,达到操控网页的无敌,利用了各种浏览器的API,达到操控浏览器的目的
Remote Web Drivers 远程运行测试(与Selenium Standalone Server或Selenium Standalone Hub进行交互时使用)
Selenium GRID 用于同时对多个操作系统的多种浏览器进行自动化测试(包括一个HUB,和多个NODE)
Language Binding 各种开发语言包

2、Selenium IDE
2.1、FF下载插件并重启
https://addons.mozilla.org/en-US/firefox/addon/selenium-ide/
2.2、录制插件

用FF打开你要测试的网站
打开Selenium IDE
Tools->Selenium IDE
输入BaseURL,点击右侧小红点儿,开始录制
在页面上进行操作(最好不要切换页面)

2.3、保存TestSuit及TestCase

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
  <title>Test Suite</title>
</head>
<body>
<table id="suiteTable" cellpadding="1" cellspacing="1" border="1" class="selenium"><tbody>
<tr><td><b>Test Suite</b></td></tr>
<tr><td><a href="neohope.case.search.html">neohope_search_testcase001</a></td></tr>
</tbody></table>
</body>
</html>

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="https://www.neohope.com/" />
<title>neohope_search_testcase001</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">neohope_search_testcase001</td></tr>
</thead><tbody>
<tr>
	<td>open</td>
	<td>/</td>
	<td></td>
</tr>
<tr>
	<td>type</td>
	<td>name=s</td>
	<td>Metabase</td>
</tr>
<tr>
	<td>clickAndWait</td>
	<td>css=button.search-submit</td>
	<td></td>
</tr>
<tr>
	<td>assertXpathCount</td>
	<td>//article</td>
	<td>1</td>
</tr>

</tbody></table>
</body>
</html>

2.4、导出python脚本
Selenium IDE->File->Export Test Case As…->Python2/WebDriver

3、用selenium-html-runner运行
3.1、下载并配置jdk
3.2、下载selenium-html-runner-3.0.1.jar
3.3、在selenium网站下载对应浏览器的driver
http://www.seleniumhq.org/download/
3.4、运行

set JAVA_HOME=C:\NeoLanguages\Java\JDK\jdk_x86_1.8.0_77
set PATH=%JAVA_HOME%\bin;%PATH%;C:\NeoTest\TestSelenium\trunk\bin\x86\;
set webdriver.gecko.driver=C:\NeoTest\TestSelenium\trunk\bin\x86\geckodriver.exe

java -jar ../lib/selenium-html-runner-3.0.1.jar -htmlSuite *firefox "https://www.neohope.com/" "../testcases/neohope.suit" "../testcases/neohope.result"
PAUSE

测试工具推荐

测试工具 适用问题 编程语言
JUnit 单元测试 Java
NUnit 单元测试 C#
PyUnit 单元测试 Python
TestUnit 单元测试 Ruby
QTP 自动化测试(BS、CS) VBS
Selenium 自动化测试(BS) Python、Ruby、Java、C#、JS
RobotFramework 自动化测试(BS) Python
Watir 自动化测试(BS) Ruby
LR 性能测试(BS、CS) C
Jmeter 接口测试、性能测试(BS) Java
SoapUI/Ready! API 接口测试、性能测试(BS) Java

其中:
1、老牌测试工具LR和QTP等,对新版本浏览器支持欠佳
2、暂时没找到很好的CS端,自动化测试工具
3、对于测试人员来说,脚本的学习曲线没有那么陡峭,建议Python或Ruby

Win10删除不想要的APP

一、Win10删掉不想要的APP
Win10会自带一些你不想要的APP,比如联系人、XBox什么的,有些可以在开始菜单右键删除,有些不让删除。下面就来删除这些你不想要的APP。
1、用管理员权限打开PowerShell
2、查看已经安装的APP

Get-appxpackage -allusers &amp;amp;gt; package.txt

3、用Vim进行处理,删除不要的行

vim package.txt
:g!/PackageFullName/d
:sort
#这样你就得到了一个排序好的程序清单

4、按要求删除程序

#命令格式
#remove-appxpackage PackageFullName
#示例:
remove-appxpackage Microsoft.BingWeather_4.25.20211.0_x64__8wekyb3d8bbwe
remove-appxpackage Microsoft.GetHelp_10.1706.13331.0_x64__8wekyb3d8bbwe
remove-appxpackage Microsoft.Messaging_4.1901.10241.0_x64__8wekyb3d8bbwe
remove-appxpackage Microsoft.Microsoft3DViewer_5.1902.20012.0_x64__8wekyb3d8bbwe
remove-appxpackage Microsoft.MicrosoftStickyNotes_3.1.53.0_x64__8wekyb3d8bbwe
remove-appxpackage Microsoft.Office.OneNote_16001.11126.20076.0_x64__8wekyb3d8bbwe
remove-appxpackage Microsoft.People_10.1812.10232.0_x64__8wekyb3d8bbwe
remove-appxpackage Microsoft.Print3D_3.3.311.0_x64__8wekyb3d8bbwe
remove-appxpackage Microsoft.Wallet_2.4.18324.0_x64__8wekyb3d8bbwe
remove-appxpackage Microsoft.WindowsAlarms_10.1812.10043.0_x64__8wekyb3d8bbwe
remove-appxpackage Microsoft.WindowsMaps_5.1812.10071.0_x64__8wekyb3d8bbwe
remove-appxpackage Microsoft.Xbox.TCUI_1.24.10001.0_x64__8wekyb3d8bbwe
remove-appxpackage Microsoft.XboxApp_48.48.7001.0_x64__8wekyb3d8bbwe
remove-appxpackage Microsoft.XboxGameCallableUI_1000.18362.449.0_neutral_neutral_cw5n1h2txyewy
remove-appxpackage Microsoft.XboxGameOverlay_1.32.17005.0_x64__8wekyb3d8bbwe
remove-appxpackage Microsoft.XboxGamingOverlay_2.26.14003.0_x64__8wekyb3d8bbwe
remove-appxpackage Microsoft.XboxIdentityProvider_12.50.6001.0_x64__8wekyb3d8bbwe
remove-appxpackage Microsoft.XboxSpeechToTextOverlay_1.21.13002.0_x64__8wekyb3d8bbwe
remove-appxpackage Microsoft.YourPhone_0.0.13313.0_x64__8wekyb3d8bbwe

二、Win10删掉不想要的库

#1、Regedit打开注册表
#2、定位到这个路径
\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace

#3、根据你想屏蔽的内容,在键值最后添加一个字符,比如X
下载{088e3905-0323-4b02-9826-5b99428e115f}
3D{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}X
未知{1CF1260C-4DD0-4ebb-811F-33C572699FDE}
图片{24ad3ad4-a569-4530-98e1-ab02f9417aa8}X
未知{374DE290-123F-4565-9164-39C4925E467B}
未知{3ADD1653-EB32-4cb0-BBD7-DFA0ABB5ACCA}
音乐{3dfdf396-dbec-4fb4-81d1-6a3438bcf4de}X
未知{A0953C92-50DC-43bf-BE83-3742FED03C9C}
未知{A8CDFF1C-4878-43be-B5FD-F8091C1C60D0}
桌面{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}
文档{d3162b92-9365-467a-956b-92703aca08af}
视频{f86fa3ab-70d2-4fc7-9c99-fcbf05467f3a}X

#4、按上面操作后,Explorer中就只有三个库了:
下载、桌面、文档

三、Win10删掉不想要的开始菜单

C:\Users\neohope\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\

Win10无法启动VirtualBox

在Win10上遇到了一个问题:

Failed to open a session for the virtual machine ubuntu.

Raw-mode is unavailable courtesy of Hyper-V. (VERR_SUPDRV_NO_RAW_MODE_HYPER_V_ROOT).

Result Code: E_FAIL (0x80004005)
Component: ConsoleWrap
Interface: IConsole {872da645-4a9b-1727-bee2-5585105b9eed}

最后发现是前几天安装了Win10的Hyper-V模块,卸载后就好了。

Win10隐私设置

1、隐藏explorer的快速访问功能

#1.1、打开注册表编辑器
regedit
#1.2、定位到下面的路径
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer
#1.3、新建一个DWORD (32-bit) Value的键值对
HubMode=1

2、关闭Cortana

#2.1、打开组策略编辑器
gepedit.msc
#2.2、定位路径
计算机配置/管理模板/Windows组件/搜索
#2.3、禁用Cortana
允许使用Cortana=已禁用

3、关闭搜索历史记录

开始/设置/Search/Permissions&amp;History
My device history = off

4、关闭TaskView历史记录

开始/设置/Privacy/Activity history
去掉Store my activity history on this device
去掉Send my activity to Microsoft
点击Clear activity history

VirtualBox的几种联网方式

VirtualBox有四种联网方式:

NAT:
虚拟机通过网络地址转换协议来访问宿主机网络,虚拟机可以访问宿主机可以访问的所有网络
宿主机和虚拟机之间无法通讯
而在宿主机局域网其他主机看来,虚拟机是不存在的
虚拟机之间不可以相互访问

Bridged:
虚拟机通过桥接,把自己虚拟为宿主机同一局域网的一台设备,虚拟机可以访问宿主机可以访问的所有网络
对于宿主机来说,虚拟机就是同一局域网的一台设备
而在宿主机局域网其他主机看来,虚拟机就是同一局域网的一台设备
虚拟机之间可以相互访问

HostOnly:
虚拟机宿主机可以相互访问,默认虚拟机不可以访问宿主机所在网络(宿主机可以共享网络给虚拟机,但一般不会这么用)。
虚拟机之间可以相互访问

Internal:
只有虚拟机之间可以相互访问。

具体情况如下(假设网段设置都正确):

通讯 Internal HostOnly NAT Bridge
虚拟机到宿主机 NO YES YES YES
宿主机到虚拟机 NO YES NO YES,部分网络服务受限
虚拟机到其他主机 NO NO YES YES,部分网络服务受限
其他主机到虚拟机 NO NO NO YES
虚拟机到虚拟机 YES YES NO YES

如何为不再有更新支持的Debain6安装软件

Debain6已经没有更新支持了

#会提示找不到更新源
apt-get update

为了继续按照软件,需要做两件事情:
1、修改/etc/apt/sources.list文件

# deb http://ftp.debian.org/debian/ squeeze-updates main contrib
# deb http://http.us.debian.org/debian/ squeeze contrib non-free main
# deb-src http://ftp.debian.org/debian/ squeeze-updates main contrib
deb http://archive.debian.org/debian squeeze main
deb http://archive.debian.org/debian squeeze-lts main

2、增加/etc/apt/apt.conf文件

Acquire::Check-Valid-Until false;