Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Facing issues after Switching back to UIA3 from UIA2 using Robotframework-flaui Library (UIA3 xpaths are not getting identified) #115

Open
vamsivarma94 opened this issue Jul 27, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@vamsivarma94
Copy link

The below is our exact scenario.

ISSUE Description: Actually we have a desktop application where we have two different xpaths when we are trying to identify an element through FLAUI Inspect tool in UIA2 and UIA3 Identifiers types. Hence in our case we would like to switch b/w UIA2 and UIA3 while Automating end to end scenario. Also for us IS_READ_ONLY is returning 'True' in UIA2 and 'FALSE' in UIA3. Hence we need to switch B/W UIA2 and UIA3.

==>Able to switch from UIA3 to UIA2 without no issues but we are facing issues when we are again switching back to our original UIA3. Able to switch back to UIA3 from UIA2 but our problem is UIA3 xpaths are not working in this case.

Scenario:isread only
Import Library FlaUILibrary uia=UIA3 screenshot_on_failure=True timeout=0 WITH NAME Custom
Reload Library Custom
importlib.Invalidate Caches
Custom.Attach Application By Pid 27308
#Set Test Variable ${uia1} UIA3
${uia} Custom.Get Uia Identifier
log to console ${uia}
Sleep 3s
${personalid_text} /Window/Window/Window/Window/Pane[1]/Pane/Pane/Edit[5] IS_READ_ONLY
log to console ${personalid_text}
############## We are trying to switch to UIA2 ############################
Import Library FlaUILibrary uia=UIA2 screenshot_on_failure=True timeout=0 WITH NAME UIA2

${uia}    UIA2.Get Uia Identifier   
   log to console     ${uia}   
${personalid_text}       UIA2.Get Property From Element   /Window/Window/Window/Window/Pane[1]/Pane[2]/Edit       IS_READ_ONLY
log to console    ${personalid_text} 
 ############## We are trying to switch back to UIA3 ############################
 # Import Library    FlaUILibrary    uia=UIA3    screenshot_on_failure=True     timeout=0    WITH NAME	UIA3Identifier 
Reload Library    Custom
importlib.Invalidate Caches 
Custom.Attach Application By Pid    27308
#Set Test Variable    ${uia1}    UIA3
${uia}    Custom.Get Uia Identifier   
   log to console     ${uia}  
   Sleep    3s 
${personalid_text}       /Window/Window/Window/Window/Pane[1]/Pane/Pane/Edit[5]    IS_READ_ONLY  #xpath belongs to UIA3 which was working earlier is not working (/Window/Window/Window/Window/Pane[1]/Pane[2]/Edit is working which is UIA2)
log to console    ${personalid_text} 
@vamsivarma94 vamsivarma94 changed the title Unable to switch back to UIA3 from UIA2 using Robotframework-flaui Library Facing issues after Switching back to UIA3 from UIA2 using Robotframework-flaui Library (UIA3 xpaths are not getting identified) Jul 27, 2023
@Nepitwin
Copy link
Member

Its important to know what value is defined by value pattern IsReadOnly

For example:

image

If it's different between UIA2 and UIA3 then the logic is fine and the different interfaces will allow you different operations. But probably it could be wrong interpreted by usage here. Pls show me your value pattern value from inspector by this element.

Afterwards your approach for an reload library is only reloading keywords but probably an new instance will be made afterwards to switch from UIA2 and UIA3.

Direct keywords from switching interface is currently not implemented.

But probably a better approach from your side would be to create two FlaUILibrarys like you do.

Library FlaUILibrary uia=UIA2 screenshot_on_failure=False WITH NAME UIA2
Library FlaUILibrary uia=UIA3 screenshot_on_failure=False WITH NAME UIA3

Afterwards you can decicde which interface you want to use in your test if they are different in element handling.

@vamsivarma94
Copy link
Author

Thank you for your immediate response. Attaching the screenshot showing the value pattern Is read only in both UIA2 and UIA3. Followed the above recommended approach for loading the two instances of library for UIA2 and UIA3. Below is my suite file.
However i got an error while using UIA3 to identify element.

*** Settings ***
Library FlaUILibrary uia=UIA2 screenshot_on_failure=True timeout=0 WITH NAME UIA2
Library FlaUILibrary uia=UIA3 screenshot_on_failure=True timeout=0 WITH NAME UIA3
*** Test Cases ***
Scenario:Is Read Only verification
${uia} UIA2.Get Uia Identifier
log to console ${uia}
${uia} UIA3.Get Uia Identifier
log to console ${uia}
${per_text} UIA2.Get Property From Element /Window/Window/Window/Window/Pane[1]/Pane[2]/Edit IS_READ_ONLY
log to console ${per_text}
${method} UIA3.Get Property From Element /Window/Window/Window/Window/Pane[1]/Pane/Pane/Pane[2]/Edit IS_READ_ONLY
Log To Console ${method}
image
image
image

Note:The same element has shows different xpath in both UIA2 and UIA3 (FLAUI Inspect).

@Nepitwin
Copy link
Member

Nepitwin commented Jul 31, 2023

Thanks for the screenshots.

So the issue is that the XPath for UIA3 is not recognized and it reports that the element cannot be found.

For the IS_READ_ONLY parameter the different interpretation of the logic is legitimate. Because this can happen that for the different interfaces also different accesses to the pattern can happen. As in the example.

Currently I see no error on your side that the Xpath would be wrong. This is exactly the right one as in the Inspector.

To narrow down the error case in the Xpath I would use the Keywords Get Childs From element.

This will output all childs as elements.

I would also build this iteratively on the Xpath.


${childs} Get Childs From Element /Window
Log ${childs}

${childs} Get Childs From Element /Window/Window
Log ${childs}

...

Until the path is complete for UIA3. From the logs you will see all the child elements of the xpath if it can be resolved.

You will also see if you are iterating over the correct XPath tree and not accidentally iterating on an element that does not belong to the expected element.

@vamsivarma94
Copy link
Author

vamsivarma94 commented Jul 31, 2023

Thanks for sharing that information.

The challenge that we are facing is w.r.t the element 'X' which is a testbox. We are trying to verify IS_READ_ONLY for this element.
While using the FlaUinspect in UIA3 mode, the value pattern IsRead Only is coming as FALSE for this element.
While using the FlaUinspect in UIA2 mode, the value pattern IsRead Only is coming as TRUE for this element. [We areactually expecting the value TRUE for this element's value pattern]

Hence while automating the testcases, we thought of using UIA2 for verifying this element and then switch back to UIA3 mode in Flauilibrary and continue the rest of the test case.

*** Settings ***
Library FlaUILibrary uia=UIA2 screenshot_on_failure=True timeout=0 WITH NAME    UIA2
Library FlaUILibrary uia=UIA3 screenshot_on_failure=True timeout=0 WITH NAME    UIA3

(Step 2) Now the following steps works fine.
    ${personalid_text} UIA2.Get Property From Element /Window/Window/Window/Window/Pane[1]/Pane[2]/Edit IS_READ_ONLY
log to console text${personalid_text}

(Step 3) Subsequently in the next steps if we are trying to use UIA3 [ex. UIA3.Get Property From Element] on any other element, then it fails to identify the element with the xpath(UIA3 xpath).

Note: Suppose we reverse the steps 2 & 3 and execute step-3 first and then step-2 then "step-3" which is uisng UIA3 is able to identify the element without any error.
Kindly refer the above 2nd comment attachments for reference.

I think it's better if we have a connect in official chat group Gitter to discuss more in detail.

@Nepitwin
Copy link
Member

I think that's what we should discuss, yes. However, I currently have no internet and wait until this is fixed.

After that I will get back to you.

@vamsivarma94
Copy link
Author

@Nepitwin can we connect to discuss further on this.

@vamsivarma94 vamsivarma94 changed the title Facing issues after Switching back to UIA3 from UIA2 using Robotframework-flaui Library (UIA3 xpaths are not getting identified) [BUG] Facing issues after Switching back to UIA3 from UIA2 using Robotframework-flaui Library (UIA3 xpaths are not getting identified) Aug 15, 2023
@vamsivarma94 vamsivarma94 changed the title [BUG] Facing issues after Switching back to UIA3 from UIA2 using Robotframework-flaui Library (UIA3 xpaths are not getting identified) [Bug] Facing issues after Switching back to UIA3 from UIA2 using Robotframework-flaui Library (UIA3 xpaths are not getting identified) Aug 15, 2023
@Nepitwin Nepitwin added the bug Something isn't working label Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants