htmlxpathautotest

How to search title in HTML using XPath?


I am trying to get 'RGF Administrator' text from the html example below. The difficulty is that title can take two values: 'Application Settings' or 'Параметры приложения'. At the same time, html may contain other elements with title = 'Application options'.

Which can i use xPath for it?

<div>
    <button
    title="Application options">
        <span>
            <span>
                <bdi>
                    RGF Administrator
                </bdi>
            </span>
        </span>
    </button>
</div>

I use selenium, but I can't determine the xPath for 'RGF Administrator'.

xpath = "//*[@title='Параметры приложения' or @title='Application options']"

won't work since at the same time, html may contain other elements with title = 'Application options'.


Solution

  • Try this xpath expression on your actual xml and see if it works:

    //div/button[@title = ('Параметры приложения', 'Application options')]//bdi/text()