This is a migrated thread and some comments may be shown as answers.

WebAii HtmlImage.IsLoaded() issue on local pages

1 Answer 55 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
bruno
Top achievements
Rank 1
bruno asked on 12 Jan 2011, 08:09 PM
Hello,

I found some strange issues when testing on local pages (file:///C:/Users/xxxxx/Desktop/Newfolder/apagar.html )

I made this simple test using WebAii:
[TestMethod]
public void SampleWebAiiTest()
{
    // Launch a browser instance
    Manager.LaunchNewBrowser(BrowserType.InternetExplorer);
 
    // The active browser
    ActiveBrowser.NavigateTo("file:///C:/Users/xxxxx/Desktop/Newfolder/apagar.html");
 
    HtmlImage image = Find.ByXPath<HtmlImage>("//img");
 
    Assert.IsNotNull(image, "It is null");
    Assert.IsTrue(image.IsLoaded(), "Not loaded");
}

The file:///C:/Users/xxxxx/Desktop/Newfolder/apagar.html content is:
<html>
<body>
<img src = "logo_emp.gif" />
</body>
</html>

When I execute this code with InternetExplorer, this is the result:
Gives error on this line: Assert.IsTrue(image.IsLoaded(), "Not loaded");
The error message:
Test method TestProject1.PrimeiroTeste.SampleWebAiiTest threw exception:  ArtOfTest.WebAii.Exceptions.ExecuteCommandException: ExecuteCommand failed!
InError set by the client. Client Error:
System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
   at mshtml.HTMLWindow2Class.IHTMLWindow2_execScript(String code, String language)
   at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeFunction(String functionCall, Boolean useEval, Boolean returnJSON)
   at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessActionCommands(BrowserCommand request)
   at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommand(WebBrowserClass ieInstance, BrowserCommand request, IHTMLDocument2 document)
BrowserCommand (Type:'Action',Info:'NotSet',Action:'InvokeJsFunction',Target:'ElementId (tagName: '',occurrenceIndex: '-1')',Data:'document.getElementsByTagName(\'img\')[0].complete',ClientId:'Client_dbcb2607-43c7-4274-a576-192dda2d1841',HasFrames:'False',FramesInfo:'',TargetFrameIndex:'-1',InError:'True',Response:'System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
   at mshtml.HTMLWindow2Class.IHTMLWindow2_execScript(String code, String language)
   at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeFunction(String functionCall, Boolean useEval, Boolean returnJSON)
   at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessActionCommands(BrowserCommand request)
   at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommand(WebBrowserClass ieInstance, BrowserCommand request, IHTMLDocument2 document)')
InnerException: none.

 The error stack trace:
ArtOfTest.WebAii.Core.Browser.ExecuteCommandInternal(BrowserCommand request)
ArtOfTest.WebAii.Core.Browser.ExecuteCommand(BrowserCommand request, Boolean performDomRefresh, Boolean waitUntilReady)
ArtOfTest.WebAii.Core.Browser.ExecuteCommand(BrowserCommand request)
ArtOfTest.WebAii.Core.Actions.InvokeScript(String script)
ArtOfTest.WebAii.BrowserSpecialized.InternetExplorer.InternetExplorerActions.InvokeScript(String script)
ArtOfTest.WebAii.Controls.HtmlControls.HtmlControl.GetValue[T](String propertyName, T defaultValue)
ArtOfTest.WebAii.Controls.HtmlControls.HtmlControl.GetValue[T](String propertyName)
ArtOfTest.WebAii.Controls.HtmlControls.HtmlImage.IsLoaded()
TestProject1.PrimeiroTeste.SampleWebAiiTest() in D:\testes_automaticos\Formacao\TestProject1\TestProject1\Formacao\Google\Tests\PrimeiroTeste.cs: line 163

Comment: Doesn't matter if image exists or not, it gives me always the same exception.

When I execute this code with FireFox, gives me:
Test passed if the image exists;
Firefox Timeout exception if the image does not exist; (if I hit esc key on firefox, it gives me "Not loaded", so it is ok, its firefox issue)

Comment: Seems that everything is ok with firefox.


When I execute this code with Chrome, gives me: "It is null"

Comment: Doesn't matter if image exists or not, the Assert.IsNull always fail.



Final comment: I found this issue by lucky, because my work does not depend on this issue. I was just doing a simple test to HtmlImage.IsLoaded() method. If the web page is not local, it works fine on all browsers.

Best Regards,

Bruno Almeida

1 Answer, 1 is accepted

Sort by
0
Keaegan
Telerik team
answered on 14 Jan 2011, 03:24 AM

Hello Bruno,

I wasn't able to reproduce this issue in the most recent internal build for WebUI (2010.3.1307). Since you are using the free version of the tool you do not have access to it. From the looks of the following line:

System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))


Due to the above error being present, this issue you are experiencing is most likely related to access to the file in question (is it in another users desktop), or in the users access to our DesignCanvas (is the user running the test an Administrator?). To test this, I created a simple website containing just an image in the body, only targeting a .jpg I have locally on my machine. I had to create two separate tests so that the Firefox one would work correctly (your coded steps force an IE window to launch and use it to test against even if Firefox is set as the browser to test against), but both worked correctly in both an Admin and Standard account in Windows 7. The standard account should be able to execute the tests, just not record them.

Please let us know if you see this in future iterations as we cannot reproduce this in the newest internal release.

Greetings,
Keaegan
the Telerik team

Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
Tags
General Discussions
Asked by
bruno
Top achievements
Rank 1
Answers by
Keaegan
Telerik team
Share this question
or