Forum Discussion

jeffrey_crowley's avatar
jeffrey_crowley
Contributor
11 years ago
Solved

querySelectorAll not working in IE8 from TestComplete 9.31

Here's some sample code that I'm using that fails on the querySelectorAll line with the following message: "Object doesn't support this property or method"




function Test()


{


    var page = Sys.Browser("iexplore").Page("*");


    page.Wait();


 


    var str = page.contentDocument.querySelectorAll("span.logo-main-a")[0].innerHTML;


    Log.Message(str);


}



The code above works on IE9/10, FF, and Chrome. When I take the simplified line below and execute it in the IE8 dev tools, it works fine.



document.querySelectorAll("span.logo-main-a")[0].innerHTML;



I thought it might be something to do with contentDocument or maybe nothing was working so I tried:

    page.contentDocument.getElementById("lpbuttondiv").innerText

and that worked fine.



So what am I missing?


  • Hi Jeff,


     


    In the TestComplete documentation, it's said that the QuerySelectorAll method isn't supported only in IE 7. It looks like our R&D team should investigate how the method works in IE 8. Could you please submit a support ticket to our Support team for this?


     


    As for the script formatting, you can use the code BBcode.


     

4 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Jeff,


     


    I suppose that you need to convert the array got from the QuerySelectorAll method (refer to this article for details):




     var arr = page.contentDocument.QuerySelectorAll("span.logo-main-a");


     var res= (new VBArray(arr)).toArray();


     // You can verify if the array isn't empty here


     var str = res[0].innerHTML;




     


    Does it work for you?

  • The problem is not the output.. it's the fact that it fails on Line 1 of your code.



    This fails in TC with the "Object doesn't support this property or method" error

    var str = page.contentDocument.querySelectorAll("span.logo-main-a");



    but this works in IE8 dev toolbar

    document.querySelectorAll("span.logo-main-a");



    I'm not sure but I don't know what else to think but it's something wrong with TestComplete. I tried getElementById() in TC and it works just fine so it doesn't seem to be the page.contentDocument or general problems with IE8 or my machine.
  • ... btw, how do you format code as code in the forums? I can't find any help pages on that. Thanks.
  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Jeff,


     


    In the TestComplete documentation, it's said that the QuerySelectorAll method isn't supported only in IE 7. It looks like our R&D team should investigate how the method works in IE 8. Could you please submit a support ticket to our Support team for this?


     


    As for the script formatting, you can use the code BBcode.