java - Issue in reading data from <p> tag using Selenium Webdriver -


my webpage shows data value need read. e.g., webpage shows like: campaign range: 05/06/2015 - 12/30/2015 budget: $50,00.99

i need read these values using selenium webdriver. structure is:

<div class="inner-widget-container">         <div class="widget-menu-container" data-bind="attr:{id: internal.controlwidgetmenuid}" id="widget-369148223195225-menu" style="display: none;"></div>         <div class="widget-data" data-bind="attr:{id: internal.controlwidgetinnercontainerid}, event:{dblclick: api.editsettings}" id="widget-369148223195225-inner" style="left: 0px; right: 0px; top: -5px; bottom: 0px;"><div class="rich-text-widget-content" style="position: absolute; left: 10px; right: 10px; height: 320px; overflow: hidden;"><div class="customhtml" style=" color:#000000 ;position: absolute;top: 0;bottom: 0; left: 0; right: 0;"> <p><span style="font-size: 24pt;">&nbsp;bmw 2015 national video youtube&nbsp;<br></span></p> <p>&nbsp;</p> <p><strong>campaign date range:</strong> 05/06/2015 - 12/31/2015&nbsp;</p> <p><strong>report date range:</strong> 10/18/2015 - 10/31/2015&nbsp;</p> <p><strong>highlights</strong></p> <p>&lt;user input&gt;</p> </div></div></div> </div> 

kindly suggest how can find campaign range element , read value?

any appreciated!!

try following css selector:

by.cssselector("div[class='customhtml'] p:nth-child(3)") 

and use gettext() desired text.

driver.findelement(by.cssselector("div[class='customhtml'] p:nth-child(3)")).gettext(); 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -