Git remove and add remote repository

如果是通过 https 方式来 pull 和 push 代码,每次都要输入烦人的账号和密码
可以通过切成成 ssh 方式:

# 取消远程仓库
git remote remove origin
<!-- more -->

# 关联远程仓库
git remote add origin git@github.com:shenxianpeng/blog.git

Nightwatch 使用 VS code 进行调试

除了通过增加

<!-- more -->
console.log('===========')

来调试 Nightwatch 代码,如何通过配置 VS code 来 Debug Nightwatch 代码?

Ctrl+Shift+D 打开 Debug 界面,配置如下:

{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"type": "node",
"request": "launch",
"name": "npm test",
"program": "${workspaceRoot}/node_modules/nightwatch/bin/runner.js",
"args": [
"tests/DQA/DQA-221/login.js"
]
}
]
}

Nightwatch 持续集成问题

在持续集成执行自动化测试用例时候会遇到那些问题呢

  1. 运行时间过长
  2. 因为某些错误程序卡住
  3. 异常处理

Read More

Nightwatch 打开多个窗口

如果想打开两个窗口并控制那个窗口怎么办?

<!-- more -->
var url = process.env.BASE_URL, newWindow;

client.execute(function (url, newWindow) {
window.open(url, newWindow, 'height=768,width=1024');
}, [url, newWindow]);

client.window_handles(function(result) {
this.verify.equal(result.value.length, 2, 'There should be 2 windows open');
newWindow = result.value[1];
this.switchWindow(newWindow);
})

Ubuntu 上使用 VPN

如何在 Ubuntu 上连接 Cisco AnyConnect VPN

打开Terminal,执行:

Read More

Ubuntu 上安装 VS Code

在 Ubuntu 下面安装 Visual Studio Code

sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make
<!-- more -->
sudo apt-get update
sudo apt-get install ubuntu-make
umake web visual-studio-code

亲测,好用。

Nightwatch wait For Text

在使用 Nightwatch 做自动化测试的时候,会遇到这样一种情况:
创建一个 query, 等待这个query的状态从 Wait 变成 Running 最后到 Available 时再执行操作。
Nightwatch 并没有提供这样的方法,可以通过下面的方式解决。

Read More

Nightwatch 元素判断

Nightwatch 元素常用验证方法

验证元素的值信息

Read More

度过工作中挫折心结

对于一个不善于言表的我工作中遇到过

  • 过度理解在与同事之间的Email和Chat中的意思;
  • 同事之间的沟通中出现的分歧事后还会继续琢磨;
  • 十分关注自己的工作失与得在上级领导中的看法。

以下方式对我来说还比较有效的

Read More

Change Hexo code highlight

Hexo 默认主题代码高亮是黑色的,如果想换个风格?具体操作如下:

# 修改 highlight.styl 文件,路径
themes/landscape/source/css/_partial/highlight.styl
<!-- more -->

修改默认代码主题 Tomorrow Night Eighties

highlight-background = #2d2d2d
highlight-current-line = #393939
highlight-selection = #515151
highlight-foreground = #cccccc
highlight-comment = #999999
highlight-red = #f2777a
highlight-orange = #f99157
highlight-yellow = #ffcc66
highlight-green = #99cc99
highlight-aqua = #66cccc
highlight-blue = #6699cc
highlight-purple = #cc99cc

为主题 Tomorrow

highlight-background = #ffffff
highlight-current-line = #efefef
highlight-selection = #d6d6d6
highlight-foreground = #4d4d4c
highlight-comment = #8e908c
highlight-red = #c82829
highlight-orange = #f5871f
highlight-yellow = #eab700
highlight-green = #718c00
highlight-aqua = #3e999f
highlight-blue = #4271ae
highlight-purple = #8959a8

更多详情请参考 tomorrow-theme 修改。

Nightwatch 测试用例失败继续执行

自动化测试中,有一个验证点,当测试通过时,后面的测试脚本继续执行;
当出现异常时,你希望标记出来这个错误,但不影响后面的测试脚本执行,在 Nightwatch 中如何做?

Read More

Hexo 配置 rss 订阅功能

安装 hexo-generator-feed 插件

npm install hexo-generator-feed --save
<!-- more -->

如果国内 npm 安装不成功,可以先安装 cnpm

npm install -g cnpm --registry=https://registry.npm.taobao.org

然后再

cnpm install hexo-generator-feed --save

在 _config.yml 中配置这个插件

feed:
type: atom
path: atom.xml
limit: 20
hub:
content:
content_limit: 140
content_limit_delim: ' '

Hexo 博客文章中插入图片

如果想在 Hexo 文章中插入图片怎么做?

网络上很容易搜到 Markdown 的语法是 ![Alt text](/path/to/img.jpg)
前面 Alt text 是指在图片下面命名,后面是图片的地址。那么如何配置?

Read More