Hello,
I have this peace of html code. See below. Now what I want to is to check if the first product (class="product-item is-full") contains "Verzekeruzelf.nl" if so click the second product the "Verder"anchor.
I am trying all kinds of things but nothing seems to work for me. See also my C# code.
I get the message:
LOG: -------------- allProducts ELEMENT FOUND: HtmlDiv:<DIV class=product-item-header>
LOG: -------------- productOne ELEMENT NOT FOUND --------------
Hope someone can help me out?
Thanks,
Bjorn
I have this peace of html code. See below. Now what I want to is to check if the first product (class="product-item is-full") contains "Verzekeruzelf.nl" if so click the second product the "Verder"anchor.
I am trying all kinds of things but nothing seems to work for me. See also my C# code.
<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>I get the message:
LOG: -------------- allProducts ELEMENT FOUND: HtmlDiv:<DIV class=product-item-header>
LOG: -------------- productOne ELEMENT NOT FOUND --------------
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 --------------");}Hope someone can help me out?
Thanks,
Bjorn