Xpath is not found on microsoft power apps

hello there!! :slight_smile:

Im trying to assert text on microsoft power apps but my xpath doesn’t work. The element here is this and I want to assert the text of XXX:

<div spellcheck="false" unselectable="off" class="appmagic-label-text" data-control-part="text" data-bind="{ inlineEditText: properties.Text, css: { 'appmagic-label-single-line': !properties.Wrap() }, attr: { 'aria-live': live, 'aria-atomic': live() ? 'true' : null } }">XXX</div>

Someone can help to understand what Im doing wrong?

this is my xpath locator:
//div[@class=‘appmagic-label-text’][text()=‘XXX’]
Element Should Contain locator XXX

I´ve also use blazemeter tool who help me to find web elements and it suggest another localor: //div[5]/div/div/div/div/div and it does not work neither.

I hope somebody with more experience can guide me to find the answer

Hi Sebastián,

microsoft power apps are dynamic (use javascript to update the page dom), so are you certain that the element you are checking is in the page at the moment in time robot tried to check it?

Robot runs quite fast and It’s quite common that it you need to add wait functions for an element to be loaded before testing it’s content.

You didn’t say which library you are using so i’ll leave you to find the suitable wait keywords for your library.

Dave.

Hi Dave, thanks a lot for your response.

As you mentioned, I put a wait function after the microsoft login finished succesfully. I also add the switch window keyword to ensure that im at the power app page. Here is my example:

Library SeleniumLibrary

keywordName
BuiltIn.Sleep 10
Get Window Titles
Switch Window TAB name Power Apps
Element Should Be visible //div[@class=‘appmagic-label-text’][text()=‘text-to-find’]
@{InicioSesion}= Get WebElements ${locator}
Should Not Be Empty ${InicioSesion}
Element Text Should Be /div[@class=‘appmagic-label-text’][text()=‘text-to-find’] ${value}

about the libraries, I´ve been trying with seleniumLibrary 4.0, autoIT and lxml without success

In your point of view, do you thing there is something else that im doing wrong?

Hi Sebastián,

Of the libraries you’ve tried SeleniumLibrary would be the best choice, so stick with that.

It would be a lot easier if I could see the site, but I’ll try to walk you through troubleshooting it.

Starting with the example you gave which step does it fail at? I’ll assume you have all the spacing correct and that it’s not a simple case of missing spaces something like this i’m guessing:

keywordName
    BuiltIn.Sleep    10
    Get Window Titles
    Switch Window    TAB name Power Apps
    Element Should Be visible    //div[@class=‘appmagic-label-text’][text()=‘text-to-find’]
    @{InicioSesion}=    Get WebElements    ${locator}
    Should Not Be Empty     ${InicioSesion}
    Element Text Should Be    /div[@class=‘appmagic-label-text’][text()=‘text-to-find’]    ${value}

(BTW create 2 lines with 3 ` on each line and put your robot script on the lines between these and the formatting and spaces will be preserved)

Some other questions to clarify what is going on in you test:

  • in your robot log how many results are in @{InicioSesion}?
  • what is the value of ${locator}? (//div[@class=‘appmagic-label-text’][text()=‘text-to-find’] ?)
  • what is the content of ${value}?

Dave.

Hi Dave,

the solution was in front of my eyes. All that I had to do was identify clearly which Iframe I´ve to call to find the elements.

BuiltIn.Sleep 7 Get Window Titles Switch Window ${HOMESCREEN.ASR.NOMBRETAB} Select Frame ${HOMESCREEN.IFRAME.SELECT}
where the iframe declare has to be just the //iframe[@class=‘publishedAppIframe’] and that´s all.

Thank you for your comments and I hope this will help to the someone.