Currently, I am working with C# and NUnit.
I have encountered an issue where I need to extract the value from a span element and store it in an ArrayList.
This is the code I am using to retrieve the price list:
var productprice = driver.FindElements(By.CssSelector(".price.mb-10.text-right "));
from the HTML snippet provided below:
<div class="pl-sec">
<ul>
<li class="row-fluid">
<li class="row-fluid">
<div class="span2">
<div class="span7 disc-content">
<div class="span3 price-content">
<div class="price mb-10 text-right"> £14.99</div>
<div class="full-width mb-20">
</div>
</li>
<li class="row-fluid">
<div class="span2">
<div class="span7 disc-content">
<div class="span3 price-content">
<div class="price mb-10 text-right"> £16.99</div>
<div class="full-width mb-20">
</div>
</li>
While I am able to retrieve the list, I am struggling to fetch the text from the elements obtained using the CSS selector.
Here is what I see in Visual Studio:
- [0] {OpenQA.Selenium.Firefox.FirefoxWebElement} OpenQA.Selenium.IWebElement {OpenQA.Selenium.Firefox.FirefoxWebElement}
+ [OpenQA.Selenium.Firefox.FirefoxWebElement] {OpenQA.Selenium.Firefox.FirefoxWebElement} OpenQA.Selenium.Firefox.FirefoxWebElement
Displayed true bool
Enabled true bool
+ Location {X = 802 Y = 793} System.Drawing.Point
Selected false bool
+ Size {Width = 164 Height = 14} System.Drawing.Size
TagName "div" string
Text "£16.99" string
I am trying to extract the 'Text' containing the price shown in the above output.
Apologies if my explanation is unclear, as I am relatively new to this concept.