or
getXpathCount(
"//img[@src=\"/images/someImage.gif\"]"
);
private
SilverlightApp App
{
get
{
return
this
.Manager.ActiveBrowser.SilverlightApps()[0];
}
}
private
HyperlinkButton Button
{
get
{
return
this
.UploadApp.FindName<HyperlinkButton>(
"_Button"
);
}
}
public
void
ClickUpload()
{
this
.Button.User.Click();
//<<==== this doesn;t fire click for button specified.
}
var mySettings =
new
Settings(BrowserType.FireFox,
"c:\\log"
);
mySettings.ClientReadyTimeout = 200000;
// Set to false if you are annoyed by red-yellow popups.
mySettings.AnnotateExecution =
true
;
mySettings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
var m =
new
Manager(mySettings);
m.Start();
m.LaunchNewBrowser();
if
(!m.ActiveBrowser.Window.IsMaximized)
{
m.ActiveBrowser.Window.Maximize();
}
m.Settings.ExecutionDelay = 100;
m.ActiveBrowser.NavigateTo(
"http://aspspider.ws/kovyar"
);
m.ActiveBrowser.AutoDomRefresh =
true
;
m.ActiveBrowser.WaitUntilReady();
Element loginfield = m.ActiveBrowser.Find.ById(
"ctl00_mainContentPlaceHolder_tbLogin"
);
Element passwfield = m.ActiveBrowser.Find.ById(
"ctl00_mainContentPlaceHolder_tbPassword"
);
m.ActiveBrowser.Actions.SetText(loginfield,
"login"
);
//just to put anything
m.ActiveBrowser.Actions.SetText(passwfield,
"pwd"
);
Element mybtn = m.ActiveBrowser.Find.ById(
"ctl00_mainContentPlaceHolder_LogInButton"
);
mybtn.As<HtmlControl>().Click();
m.ActiveBrowser.WaitForUrl(
"StartPage.aspx"
,
true
, 10000);
m.ActiveBrowser.WaitForFrame(
new
FrameInfo(
"MainFrameSet"
,
null
,
null
, 0), 10000);
m.ActiveBrowser.RefreshDomTree();
var mf = m.ActiveBrowser.Frames.ById(
"MainFrameSet"
);
m.ActiveBrowser.WaitForFrame(
new
FrameInfo(
"frmLeft"
,
string
.Empty,
string
.Empty, 0), 10000);
m.ActiveBrowser.RefreshDomTree();
var f = m.ActiveBrowser.Frames.ById(
"frmLeft"
);
f.WaitUntilReady();
f.RefreshDomTree();
var t = f.Find.ById<HtmlInputText>(
"treeFilterText"
);
t.Click();
// this method doesn't work
t.Text =
"Hey Test!"
;
// neither does that.
ArtOfTest.WebAii.Exceptions.ExecuteCommandException: ExecuteCommand failed!
InError set by the client. Client Error:
mozCommandProcessor: FindElement(): Tag collection is either empty or has less elements than the element occurrence requested.TagName: , Occurrence Requested: -1, All Tags Collection length: 0
BrowserCommand (Type:'Information',Info:'FrameRectangle',Action:'NotSet',Target:'null',Data:'2',ClientId:'Client_8c806e49-0c9d-48ed-a729-e2c2d2978a5c',HasFrames:'False',FramesInfo:'',TargetFrameIndex:'-1',InError:'True',Response:'mozCommandProcessor: FindElement(): Tag collection is either empty or has less elements than the element occurrence requested.TagName: , Occurrence Requested: -1, All Tags Collection length: 0')
InnerException: none.
at ArtOfTest.WebAii.Core.Browser.ExecuteCommandInternal(BrowserCommand request)
at ArtOfTest.WebAii.Core.Browser.ExecuteCommand(BrowserCommand request, Boolean performDomRefresh, Boolean waitUntilReady)
at ArtOfTest.WebAii.Core.Browser.ExecuteCommand(BrowserCommand request)
at ArtOfTest.WebAii.Core.FrameInfo.GetRectangle()
at ArtOfTest.WebAii.ObjectModel.Element.GetRectangle()
at ArtOfTest.WebAii.Core.Actions.AnnotateElement(Element targetElement, String message, Boolean isNative)
at ArtOfTest.WebAii.Core.Actions.AnnotateElement(Element targetElement, String actionName, String data, Boolean isNative)
at ArtOfTest.WebAii.Core.Actions.Click(Element targetElement)
at ArtOfTest.WebAii.Controls.HtmlControls.HtmlControl.Click()
at Tests.Test.Test1() in Test.cs: line 60
Settings mySettings =
new
Settings(BrowserType.FireFox, @
"d:\"
);
mySettings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
Manager myManager =
new
Manager(mySettings);
myManager.Start();
myManager.LaunchNewBrowser();
myManager.ActiveBrowser.NavigateTo(
"file:///d:/test.html"
);
Element mybtn = myManager.ActiveBrowser.Frames[0].Find.ByName(
"press_me"
);
HtmlControl htmlControl =
new
HtmlControl(mybtn);
//fine in IE and FF
htmlControl.Click();
//error in FF only
htmlControl.MouseClick(MouseClickType.LeftClick);
//error in FF only
myManager.Desktop.Mouse.Click(MouseClickType.LeftClick, mybtn.GetRectangle());
//error in IE and FF
myManager.ActiveBrowser.Actions.Click(mybtn);
//error in FF and IE
myManager.ActiveBrowser.Actions.InvokeEvent(mybtn, ScriptEventType.OnClick);
myManager.Dispose();
<
html
>
<
head
></
head
>
<
frameset
cols
=
"25%,*,25%"
>
<
frame
src
=
"frame_a.html"
/>
<
frame
src
=
"frame_b.html"
/>
<
frame
src
=
"frame_c.html"
/>
</
frameset
>
</
html
>
<
html
>
<
body
>
<
input
type
=
"button"
name
=
"press_me"
value
=
"press_me"
onclick
=
"alert('Hello world!')"
/>
</
body
></
html
>
Unhandled Exception: ArtOfTest.WebAii.Exceptions.ExecuteCommandException: Execut
eCommand failed!
InError set by the client. Client Error:
System.ArgumentException: Tag collection is either empty or has less elements th
an the element occurrence requested. RequestedIndex: '0', ElementLength: '0'
at ArtOfTest.InternetExplorer.IECommandProcessor.FindElement(ElementIdMessage
id)
at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessActionCommands(Browse
rCommand request)
at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommand(WebBrowserCla
ss ieInstance, BrowserCommand request, IHTMLDocument2 document)
BrowserCommand (Type:'Action',Info:'NotSet',Action:'Click',Target:'ElementId (ta
gName: 'input',occurrenceIndex: '0')',Data:'',ClientId:'Client_44818831-9568-46b
5-9a23-3ad5285d5c64',HasFrames:'False',FramesInfo:'',TargetFrameIndex:'-1',InErr
or:'True',Response:'System.ArgumentException: Tag collection is either empty or
has less elements than the element occurrence requested. RequestedIndex: '0', El
ementLength: '0'
at ArtOfTest.InternetExplorer.IECommandProcessor.FindElement(ElementIdMessage
id)
at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessActionCommands(Browse
rCommand request)
at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommand(WebBrowserCla
ss ieInstance, BrowserCommand request, IHTMLDocument2 document)')
InnerException: none.
at ArtOfTest.WebAii.Core.Browser.ExecuteCommandInternal(BrowserCommand reques
t)
at ArtOfTest.WebAii.Core.Browser.ExecuteCommand(BrowserCommand request, Boole
an performDomRefresh, Boolean waitUntilReady)
at ArtOfTest.WebAii.Core.Browser.ExecuteCommand(BrowserCommand request)
at ArtOfTest.WebAii.Core.Actions.Click(Element targetElement)
at testMouseClick.Program.Main(String[] args) in C:\Documents and Settings\My Documents\Visual Studio 2008\Projects\testMouseClick\testMouseClick
\Program.cs:line 42