小编dof*_*mac的帖子

如何用watin来测试Ajax wedsites?

//使用watin测试一些ajax网站,当点击td时,div("appendProdctTreeDiv")将显示一些响应html,但我不知道如何获得这个div innerhtml并点击我想要的链接; 可以通过测试"http://www.google.com/ig"?thanks提前给出一些例子!


------使用watin --------
IE ie = new IE();
....
ie.Element(Find.ById("tree")).Click();
textbox1.text = ie.Div("appendProdctTreeDiv").innerHtml; //这种方式错了;
...


..html代码..

<'TD id = tree onclick = showAppendProductTree()noWrap> tab1 <'/ TD>

....

<'DIV style ="WIDTH:100%; HEIGHT:96%; OVERFLOW:auto"id = appendProdctTreeDiv loaded ="false"> <'/ DIV>
....


function showAppendProductTree(){

showTreeTab(3);
Run Code Online (Sandbox Code Playgroud)

if(document.getElementById("appendProdctTreeDiv").loaded =="false"){

    var url ="product!changeAppendProduct.do";

var params = "";

var newProductId = document.getElementById("newProductId").value;
    new Ajax.Request(
    url,
    {
        method: 'get',
        parameters: params+"&random="+Math.random(),
        requestHeaders:["Cache-Control","no-cache"],
        onComplete: function(originalRequest){  
        var message = originalRequest.responseText;
        document.getElementById("appendProdctTreeDiv").innerHTML= message;
        document.getElementById("appendProdctTreeDiv").loaded = "true";
                    synAppendTree();
        document.getElementById("waitLoadAppendProd").style.display = …
Run Code Online (Sandbox Code Playgroud)

ajax watin

2
推荐指数
1
解决办法
2433
查看次数

标签 统计

ajax ×1

watin ×1