Pir
Pir

Reputation: 1

PHP-Webdriver how to get Text from Span Tag

This is a span tag which I have:

    <span id="CD417" oncontextmenu="myR(this)" style="cursor: pointer;" spanparent="RD417" reportinfostring="417|N|N|K1|1">
        <img src="images/mydocument.gif" title="Rep" style="width:24px; height:24px;" spanparent="RD417" reportinfostring="417|N|N|K1|1" border="0">
        This_is_the_Text_I_Need_To_Get
    </span>

I'm looking for "This_is_the_Text_I_Need_To_Get" and this is part of my code:

        $items = $driver->findElements(WebDriverBy::tagName("span"));
        foreach ($items as $item) {
            if ( $item->getAttribute('id') != "" ) {
                echo "Item ID: "; var_dump($item->getAttribute('id'));
                echo "Item getText: "; var_dump($item->getText());
                echo "Item innerHTML: "; var_dump($item->getAttribute('innerHTML'));
            }
        }

And what I got:

Item ID: string(10) "CD417"
Item getText: string(0) ""
Item innerHTML: NULL

What should I do?

Upvotes: 0

Views: 280

Answers (1)

PanDagger
PanDagger

Reputation: 1

$item->getDomProperty('innerHTML')

Upvotes: 0

Related Questions