or
// close the mock app
ActiveApplication.Quit();
string
appPath =
string
.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs), @
"\MyWPFApp\DEVELOPMENT\MyWPFApp.appref-ms"
);
System.Diagnostics.Process.Start(appPath);
var runningApp = System.Diagnostics.Process.GetProcesses().Where(p => p.ProcessName ==
"MyAPP"
);
while
(runningApp.Count() == 0)
{
runningApp = System.Diagnostics.Process.GetProcesses().Where(p => p.ProcessName ==
"MyAPP"
);
}
Manager.ConnectToApplication(runningApp.FirstOrDefault());
while
(!Manager.ActiveApplication.Process.WaitForInputIdle())
Manager.ActiveApplication.MainWindow.RefreshVisualTrees();
ActiveApplication.WaitForWindow(
"My App"
);
<
div
class
=
"product-items"
id
=
"product-items"
>
<
div
class
=
"product-item is-full"
>
<
div
class
=
"product-item-header"
>
<
span
class
=
"icon-prijs-kwaliteit"
>
<
span
class
=
"inner-circle"
>1</
span
>
</
span
>
<
div
class
=
"row-fluid row-fluid-centered"
>
<
div
class
=
"grid2of3"
>
<
div
class
=
"product-item-company"
>Verzekeruzelf.nl</
div
>
</
div
>
</
div
>
</
div
>
<
div
class
=
"product-item-body s-visible-block"
>
<
div
class
=
"row-fluid row-fluid-centered"
>
<
div
class
=
"grid2of3"
>
<
span
class
=
"price-quality-label"
>Prijs-kwaliteit</
span
>
<
div
class
=
"price-quality-score"
>100</
div
>
</
div
>
</
div
>
</
div
>
<
div
class
=
"product-item-footer"
>
<
div
class
=
"product-item-price"
><
sub
>per maand: </
sub
>30,<
sup
>21</
sup
></
div
>
<
a
href
=
"/autoverzekering/details/overzicht/50162"
class
=
"btn-purple"
>Verder</
a
>
</
div
>
</
div
>
<
div
class
=
"product-item is-full"
>
<
div
class
=
"product-item-header"
>
<
span
class
=
"icon-prijs-kwaliteit"
>
<
span
class
=
"inner-circle"
>2</
span
>
</
span
>
<
div
class
=
"row-fluid row-fluid-centered"
>
<
div
class
=
"grid2of3"
>
<
div
class
=
"product-item-company"
>Allsecur</
div
>
</
div
>
</
div
>
</
div
>
<
div
class
=
"product-item-body s-visible-block"
>
<
div
class
=
"row-fluid row-fluid-centered"
>
<
div
class
=
"grid2of3"
>
<
span
class
=
"price-quality-label"
>Prijs-kwaliteit</
span
>
<
div
class
=
"price-quality-score"
>92</
div
>
</
div
>
</
div
>
</
div
>
<
div
class
=
"product-item-footer"
>
<
div
class
=
"product-item-price"
><
sub
>per maand: </
sub
>30,<
sup
>48</
sup
></
div
>
<
a
href
=
"/autoverzekering/details/overzicht/50869"
class
=
"btn-purple"
>Verder</
a
>
</
div
>
</
div
>
</
div
>
ActiveBrowser.RefreshDomTree();
//HtmlDiv productOne = Find.ByExpression<HtmlDiv>("class=product-item-header"); //Grab the first company
IList<HtmlDiv> allProducts = Find.AllByAttributes<HtmlDiv>(
"class=product-item-header"
);
if
(allProducts !=
null
) {
Log.WriteLine(
"-------------- allProducts ELEMENT FOUND: "
+ allProducts[0].ToString());
//HtmlDiv NameCompanyOne = top3[0].Find.ByNodeIndexPath<HtmlDiv>("1/0/0");
//Log.WriteLine("-------------- VERZEKER ONE NAME: " + NameCompanyOne.InnerText);
HtmlDiv productOne = allProducts[0].Find.ByAttributes<HtmlDiv>(
"class=product-item-company"
);
if
( productOne !=
null
) {
if
( productOne.InnerText.Contains(
"Verzekeruzelf.nl"
) ) {
//Check if it's Verzekeruzelf.nl
Log.WriteLine(
"-------------- VERZEKER U ZELF FOUND --------------"
);
//First company is Verzekeruzelf.nl
HtmlAnchor anchorCompanyTwo = allProducts[1].Find.ByExpression<HtmlAnchor>(
"value=Verder"
);
//Grab Verder link
anchorCompanyTwo.Click();
//Click it
}
else
{
Log.WriteLine(
"-------------- NO VERZEKER U ZELF FOUND --------------"
);
//First company not is Verzekeruzelf.nl
HtmlAnchor anchorCompanyTwo = allProducts[0].Find.ByExpression<HtmlAnchor>(
"value=Verder"
);
//Grab Verder link
anchorCompanyTwo.Click();
//Click it
}
}
else
{
Log.WriteLine(
"-------------- productOne ELEMENT NOT FOUND --------------"
);
}
}
else
{
Log.WriteLine(
"-------------- allProducts ELEMENT NOT FOUND --------------"
);
}