To resolve the issue that resolv.conf is rewritten each time after reboot unbuntu

My working PC is Ubuntu 11.10. Each time after reboot I find that resolv.conf is cleared, and I can not access website.

To resolve this issue, just try the following command

$ sudo chattr +i /etc/resolv.conf

Next time after reboot unbuntu you can see that resolv.conf is kept as what it should be.

发表在 common | 留下评论

send email via python smtplib

Sometime when testing email related function, we may use the following script to help to identify issues.

import smtplib
to = 'to_email@abc.com'
gmail_user = 'from_gmail@gmail.com'
gmail_pwd = 'from_gmail_password'
smtpserver = smtplib.SMTP("smtp.gmail.com",587)
smtpserver.starttls()
smtpserver.login(gmail_user, gmail_pwd)
header = 'To:' + to + '\n' + 'From: ' + gmail_user + '\n' + 'Subject:testing \n'
print header
msg = header + '\n This msg is sent from me, for testing purpose.\n\n'
smtpserver.sendmail(gmail_user, to, msg)
print "This email is sent from gmail account '" + gmail_user + "' to user '" + to + "'. \n\n" + "Please check whether your receive the email in '" + to + "'"
smtpserver.close()

发表在 common | 留下评论

To config pydev in eclilpse

1. Download and launch eclipse
2. Config pydev in eclipse
click Help -> Install New Software -> Add
then enter the following
Name: pydev
url : http://pydev.org/updates
3. Config python interpreter
click Window -> Preference -> PyDev -> Interpreter-Python, then click “Auto Config”

发表在 automation-testing, common | 留下评论

Config python + selenium 2.0/webdriver development environment on Win7(Win64bit)

1. Download and install jdk, then add the dir of java to system variable – path.
Note: If you are not sure how to add one dir to system variable Path, please refer to the followin steps; otherwise please skip this.
(1) Right click “Computer” in Desktop, select and click Prefernce (属性)
(2) Click “Advanced System Settings” (高级系统设置)
(3) In the pop up window, click Advanced (高级) tab, then click “Environment Variable” (环境变量)
(4) Under “System Variable” (系统变量) click Path
(5) In the pop up “Edit System Variable” window, add your java.exe dir to Path. e.g. your java.exe path is C:\yourpath, the original Path is “%SystemRoot%\system32″, after edit it should be “%SystemRoot%\system32;C:\yourpath”
2. Download and install python
3. Add dir of python.exe to system variable – Path
4. Download and install ez_setup.py by run command “python ez_setup.py”, then add dir of easy_install.exe (e.g. D:\your_python_installation_dir\Scripts) to system variable – Path
5. Download and install pip (python setup.py install), then add dir of pip (D:\your_python_installation_dir\Scripts) to system variable.
6. Setup virtualenv
(1) run “pip install virtualenv”
(2) make sure dir of virtualenv.exe is in system environment variable
(3) create working dir for your coding project, under it run “virtualenv MyEnv”
(4) go to MyEnv\Scripts run “activate.bat”
7. Under “MyEnv” Run “pip install selenium”

发表在 automation-testing, common | 留下评论

webdriver在firefox中处理http auth

一个网站用http auth对自动化测试来说是个挑战。selenium1.0试了很多次,都解决不了http auth的问题。木有想到webdriver发布以后,对http auth的处理有所改善。以下就是webdriver在firefox中处理http auth的方法(auth窗口不再弹出)。

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

profile = webdriver.FirefoxProfile()
profile.set_preference('network.http.phishy-userpass-length',255)
driver = webdriver.Firefox(firefox_profile=profile)
driver.get("http://username:password@yourwebsite.com")

继续探索,看看webdriver能否处理httpauth在其他浏览器中的情况。

发表在 automation-testing | 标签为 , , , | 留下评论

Aptana – 配置python interpreter时出错

在Mac上的Aptana Studio 3.0中配置python interpreter的时候,总是出错,被告知:
Python stdlib not found or stdlib found without .py files
检查python版本,是python 2.7.1,高于python2.5,且python shell运行良好,应该木问题啊。
最后安装了xcode 4.2终于搞定。原来醉翁之意不在酒的。

发表在 common | 标签为 | 留下评论

Eclipse Editor字体颜色配置问题

Eclipse 3.5.2 在Mac上运行起来后,Editor里面的字体设置相当难看,且颜色配置不当,package name几乎看不见。

Eclipse_editor

下载新的color theme plugin, 希望能解决这个问题。

详情见 http://www.beautifycode.com/fdt4-color-themes

发表在 common | 标签为 | 留下评论

QTP object spy does not work

Investigating QTP, and find that sometimes object spy does not work. That is, try to capture web object in IE 8 using object spy, while it can not find input box or buttons in its proper position. Time consuming, God.
Finally find the the resolution – change zoom of IE to 100%.

发表在 common | 标签为 , | 留下评论

To checkout code from git branch

某些项目代码放在branch而不是master, 如果需要从branch上拿代码,运行以下命令即可
git clone
git checkout -b origin/
git branch -D master
最后一条是为了删除mater,可示情况来定是否运行

发表在 common | 留下评论

intelij idea失焦点的问题

Ubuntu下,发现在多程序间转换的时候,Intelij IDEA常常失去焦点。若想编辑某文件,每次必须重新双击该文件名,精疲力尽。后来发现这是由于输入法scim导致的。卸载了scim,用fcitx,这个问题就解决了。偶滴神哪~

发表在 common | 标签为 | 留下评论