About neohope

一直在努力,还没想过要放弃...

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

Redash环境搭建(Ubuntu)

1、下载安装脚本

wget -O bootstrap.sh https://raw.githubusercontent.com/getredash/redash/master/setup/ubuntu/bootstrap.sh

2、运行脚本

chmod +x bootstrap.sh
sudo ./bootstrap.sh

3、脚本执行成功后,直接访问nginx就好了
http://ip:80
实际上是代理了这个网站
http://localhost:5000

4、常见问题
在执行过程中,遇到下载失败的情况,就直接把文件下载到本地,改一下路径,重新运行脚本就好了
我在运行脚本的过程中,遇到了缺少schema的提示,删除了数据库redash及用户redash,重新运行脚本就好了

Superset环境搭建(Ubuntu)

1、安装依赖包

sudo apt-get install build-essential libssl-dev libffi-dev python-dev python-pip libsasl2-dev libldap2-dev
pip install virtualenv

2、使用虚拟环境

#新建沙盒
virtualenv supersetenv
#进入沙盒
source bin/activate

3、安装

#升级安装工具,安装服务
pip install --upgrade setuptools pip
pip install superset
#新增管理员用户
fabmanager create-admin --app superset
#重置管理员密码
#fabmanager reset-password admin --app superset
#升级数据库
superset db upgrade
#加载测试数据
superset load_examples
#初始化
superset init
#运行Server
superset runserver

4、此时,只需要访问http://ip:8088就可以登陆了

5、安装驱动

#mysql
apt-get install libmysqlclient-dev
pip install mysqlclient
#oracle
#pip install cx_Oracle
#mssql
#pip install pymssql

6、关闭

#Ctrl+C关闭Server
#退出沙盒
deactivate
#删除沙盒
#rmvirtualenv supersetenv

7、升级

#进入沙盒
source bin/activate
#升级Server
pip install superset --upgrade
#升级DB
superset db upgrade
#初始化
superset init
#退出沙盒
deactivate

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\

安装GitBook环境

1、安装

# npm install gitbook
# npm install ebook-convert
npm install gitbook-cli -g 
gitbook install

2、设置国内源

npm config set registry https://registry.npmjs.org/
npm config set registry https://registry.npm.taobao.org

3、增加转PDF支持

# windows
https://calibre-ebook.com/download_windows64

#linux
sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sudo sh /dev/stdin
sudo apt-get install libfontconfig1 libxcomposite1 libxdamage1 libxfixes3 libgl1

#linux字体安装
#将需要的字体拷贝到这个文件夹
#/usr/share/fonts/truetype/winfonts
#刷新
sudo fc-cache -fv
#确保ubuntu认到字体
fc-list :lang=zh-cn

4、基本操作

# 新建一本书的目录结构
gitbook init

# 开启网站查看书的内容
gitbook serve .

# 图书生成pdf
gitbook pdf .

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