0

I want to find the element "Holiday4" in span class="fc-title". How to do it? Do i need to use css selector or do I need to use xpath?

<tr>

    <td class="fc-day-number fc-sun fc-future hp-cal-selected" data-date="2016-02-14">14</td>
    <td class="fc-day-number fc-mon fc-future" data-date="2016-02-15">15</td>
    <td class="fc-day-number fc-tue fc-future" data-date="2016-02-16">16</td>
    <td class="fc-day-number fc-wed fc-future" data-date="2016-02-17">17</td>
    <td class="fc-day-number fc-thu fc-future" data-date="2016-02-18">18</td>
    <td class="fc-day-number fc-fri fc-future" data-date="2016-02-19">19</td>
    <td class="fc-day-number fc-sat fc-future" data-date="2016-02-20">20</td>

</tr>

<tr>

    <td class="fc-event-container">

        <a class="fc-day-grid-event fc-h-event fc-event fc-start fc-end holiday" style="color:65280" title="Holiday">

            <div class="fc-content">
                <span class="fc-title">Holiday4</span>
            </div>

        </a>
shiva
  • 47
  • 2

4 Answers4

0

Use cssSelector

.fc-content [div:contains('Holiday 4')]

Also check this out Need to find element in selenium by css

https://saucelabs.com/selenium/css-selectors

Community
  • 1
  • 1
Omar Alves
  • 763
  • 5
  • 13
0

If to use Python:

from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://your_url.com')
element = driver.find_element_by_xpath('//span[@class="fc-title"][contain(text(),"Holiday 4")]')
Andersson
  • 51,635
  • 17
  • 77
  • 129
0

Use Below Xpath,

//span[@class='fc-title'][.='Holiday4']
SacTan
  • 379
  • 2
  • 5
  • 18
0

To get the Text of "Holiday4" you can find it by the following.

Using Css Selector:

string str = driver.FindElement(By.CssSelector("[class='fc-title']")).Text;

Using XPath:

string str = driver.FindElement(By.Xpath("tr/td/a/div/span")).Text;
Madhu
  • 479
  • 4
  • 10