解决Selenium无法type富文本的问题
上一篇 / 下一篇 2011-08-06 13:39:33 / 个人分类:自动化测试
import static org.junit.Assert.*;51Testing软件测试网1y8Db/`-~`(C^!D
import java.util.Date;51Testing软件测试网 m;l]FO2i8?4U
import com.thoughtworks.selenium.*;51Testing软件测试网'uYT&_7Q?A.z*k)\
/**51Testing软件测试网D*f:Wk o+kO]
* 自动发布宝贝51Testing软件测试网0f7Z:I9CC]
*/51Testing软件测试网p:i-\ M(su
public classTestAddBaibeiextends Search {
public static Selenium localSelenium;
'V4c/M*y-g051Testing软件测试网:Bctj5kn%UL@Before51Testing软件测试网 W^M5IBF!vkWhE,P"r
public void init() {
\&P\i,P;Y(u0localSelenium = selenium;
f8B-X]MY_8l*sn0}51Testing软件测试网6Q_A.^-H
n7rl0~)`~0/**51Testing软件测试网Ymg8{#f5P e
* 登录,填写宝贝信息,发布
J+{|~5X,[F?5SS8S0*/51Testing软件测试网)\R IW*hd
@Test51Testing软件测试网6A x/Qo Ri
h
public void test_addBaobei(){
N9c2w(}]q&D0// 登录51Testing软件测试网,i e r2Ni b7\
open(" http://login.taobao.com/member/login.jhtml ");
.m/j.n KdZVg0String xpath = "//input[@id='TPL_username_1']";
T`9XC4`8Erz0selenium.type(xpath, "c测试账号23");51Testing软件测试网Z-F^wVD
selenium.type("//input[@name='TPL_password']", "taobao1234");51Testing软件测试网lv"VSgj2nk5NKG
selenium.click("//button[@class='J_Submit']");51Testing软件测试网xS w6K3L*S3O
//Util.mySleep(5000);51Testing软件测试网:\Lr*l+l'}:PB
for(int i=1;i<100;i++){51Testing软件测试网9LF'C$P}1d;| Q
open(" http://upload.taobao.com/auction/publish/publish_by_spu.htm?spu_id=93088587&auction_type=b&auction_id=&item_num_id=10588813056&wirelessOption=&wirelessmpChoosed=&isEdit=false");51Testing软件测试网i0Oo$KeuUp.m6n
51Testing软件测试网,r2E+]~C3Y.@x
/*添加宝贝基本信息*/51Testing软件测试网c2SOK
X:^
selenium.click ("//input[@id='on1']"); //全新51Testing软件测试网E;k'BW.r~e
selenium.select("//select[@id='prop_32731']", "商务休闲"); //风格51Testing软件测试网)|#i-hVB5v4PFa
//selenium.select("//select[@id='prop_6900399']", "嘻哈"); //风格细分
?a]5G
r%\0selenium.type("//input[@name='_fma.pu._0.ti']","新宝贝"+i); //宝贝标题+i51Testing软件测试网7h7b6[6zk
selenium.type("//input[@name='_fma.pu._0.m']","2000"); //一口价
7@&Q[S
^4Cr0selenium.click("//input[@id='prop_20503_28383']"); //均码51Testing软件测试网UI2HOn*lE
selenium.type("//input[@id='sale_p_15']","2000"); //标准套餐价格
6}Zb
{k9Hxq.G0selenium.type("//input[@id='sale_q_15']","1"); //标准套餐数量
"r'a/o8@eK)|Q9s0selenium.type("//input[@name='_fma.pu._0.q']","1"); //宝贝数量
;zJfE"Q0Util.mySleep(5000);51Testing软件测试网N%Ynp"plq4U*z
selenium.click("//a[@data-detect='picSpace']"); //上传图片51Testing软件测试网@&_FN]sx!w
selenium.click("//div[@id='J_List']/ul/li/a[@title='Asus华硕']"); //点击图片
{4W8M*Gb&X8v8FZ$ZT0//selenium.type("//body[@class='ke-editor']","测试发表宝贝描述"); //宝贝描述.这样是添加不进富文本Iframe的,可用以下方法51Testing软件测试网e3Z1m*\%|k
selenium.selectFrame("//iframe[@title='kissy-editor']");51Testing软件测试网OB&CeK#p)o SI
selenium.getEval("selenium.browserbot.getCurrentWindow().document.body.innerHTML=\"测试发表宝贝描述\";");51Testing软件测试网t\d
[#xvC:Xq`2q
selenium.selectFrame("relative=up");
?T'E+CY.d+d
zD4Kg0Util.mySleep(10000);
u,{kTKN7F(c6flW0/*添加宝贝物流信息*/
3ZBx^w S3\0T.p/O1x0selenium.select("//select[@id='J_province']", "北京"); //所在地51Testing软件测试网/Q%Uhr@3yE
selenium.click("//input[@id='isApplyPostage_false']"); //运费
1nx"de
[0selenium.type("//input[@id='pyTF']","10"); //一口价
s|zC+g%s0selenium.type("//input[@id='kdTF']","15"); //标准套餐价格
9^td\ v+QR"} q0selenium.type("//input[@id='emsTF']","20"); //EMS51Testing软件测试网?qG2]a;Z
Util.mySleep(5000);51Testing软件测试网.gL&co*lp+o0u
.U7n*CTz051Testing软件测试网2M2m/TC"C"_%^6[
/* other info*/
(q6l"m#^)SxV ]0selenium.click("//input[@id='durationId14']"); //有效期
P,Q6eO(dYh0selenium.click("//input[@id='event_submit_do_publish']");51Testing软件测试网`CvV? zc DF(r$Q \
//Util.mySleep(5000);51Testing软件测试网 kG|Uo
}51Testing软件测试网4?*^^)F(QK'G a
d`"W9q
}
相关阅读:
- selenium (tobecy, 2011-8-09)
- (转)以交互模式使用Selenium (phoenix_lo, 2011-8-10)
- selenium使用 (abgg, 2011-8-10)
- (转)维基-Selenium函数说明 (phoenix_lo, 2011-8-10)
- 转 Web应用自动化验收工具——Selenium系列 (jingwdongw, 2011-8-23)