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

ComboBox.GetAllItems fails on non-English Windows OS #31

Open
brian-mcmaster opened this issue Jun 7, 2016 · 11 comments
Open

ComboBox.GetAllItems fails on non-English Windows OS #31

brian-mcmaster opened this issue Jun 7, 2016 · 11 comments

Comments

@brian-mcmaster
Copy link

Specifically, because it hard-codes English strings when looking for sub-controls and control types, such as "Open" and "list_item". These captions are localized on other OS's... i.e. on Spanish these captions are "Abrir" and "elemento de listo," respectively. Here is the diff of how I fixed it. Replaced "Open" with "*" since there should only be one button-type control as a child of a combobox. Also replaced "list_item" with the ControlType.ListItem property. I had to add the element's control type to the propertyHT in Utils.cs at the bottom.

This is just the first issue I encountered running one of our tests in localized OS. I imagine there are many other hard-coded strings in LDTP.

==== cobra-master\Ldtpd\Combobox.cs ====
168c168,169

< elementItem = utils.GetObjectHandle(childHandle, "Open", type, true);

            // find the Open button, but use '*' as the caption since it gets localized on different OS's
            elementItem = utils.GetObjectHandle(childHandle, "*", type, true);

207,208c208,210
< case "Verify":

< elementItem = utils.GetObjectHandle(childHandle, "Open",

                        case "Verify":
                            // find the Open button, but use '*' as the caption since it gets localized on different OS's
                            elementItem = utils.GetObjectHandle(childHandle, "*",

238,239c240,242
< LogMessage("GetComboValue");

< elementItem = utils.GetObjectHandle(childHandle, "Open",

                            LogMessage("GetComboValue");
                            // find the Open button, but use '*' as the caption since it gets localized on different OS's
                            elementItem = utils.GetObjectHandle(childHandle, "*",

298,299c301,303
< InternalTreeWalker w = new InternalTreeWalker();

< elementItem = utils.GetObjectHandle(childHandle, "Open",

                            InternalTreeWalker w = new InternalTreeWalker();
                            // find the Open button, but use '*' as the caption since it gets localized on different OS's
                            elementItem = utils.GetObjectHandle(childHandle, "*",

330c334

< className.Contains("list_item"))

                                    propertyHT["control_type"] == ControlType.ListItem)

==== cobra-master/Ldtpd/Utils.cs#1 - d:\dev\experience-dev\product-tests\third-party\LDTP\cobra-master\Ldtpd\Utils.cs ====
894a895
propertyHT.Add("control_type", element.Current.ControlType);

@nagappan
Copy link
Member

nagappan commented Jun 8, 2016

Can you please provide a patch, will pull the changes in. Thanks reporting this issue, I was not aware of it.

@brian-mcmaster
Copy link
Author

Never done this before. Here's your patch. Hope it worked!

0001-Removing-hard-coded-English-strings-in-ComboBox-so-i.zip

@rrzaripov
Copy link
Contributor

@brian-mcmaster ok, I try to apply this patch and rebuild msi package. But I need some test case example for validate result. And for the future, use the pull-requests for sending patches;)

@brian-mcmaster
Copy link
Author

Sorry, I don't know git at all. I'll research pull requests next time. To test it, you need to install a non-English OS. Note that you need to translate the strings to whatever language you're testing... but you get the idea.

  1. Bring up Paint
  2. Click File | Save as... (Archivo | Guardo como)
  3. python
  4. import ldtp
  5. ldtp.getallitem("Save As", "cboSaveastype") ldtp.getallitem("Guardar como", "cboTipo")

Results: you get an empty list on Spanish OS
Expect: you should get a list of the file types in the combobox dropdown

It fails because the "Open" button's caption is not "Open," so it can't drop down the list. Once you fix that, it fails because the item types it's looking for are "list-item", but that is also localized.

@rrzaripov
Copy link
Contributor

@brian-mcmaster thank you for detailed test case! After testing I will make pull request to upstream. Stay tuned!

rrzaripov added a commit to rrzaripov/cobra that referenced this issue Jun 15, 2016
rrzaripov added a commit to rrzaripov/cobra that referenced this issue Jun 27, 2016
@rrzaripov
Copy link
Contributor

@brian-mcmaster can you please test this build, they include patch from you. I was run test using scenario that you given me in previous comment, but I still got empty list (tested on Windows 7, russian locale, "File type" combobox in "Save as" dialog in mspaint):

>>>from ldtp import *
>>> getallitem(u"frmСохранить как", u"cboТипфайла")
[]

You can look at changes, that applyed to this build in this commit. Maybe I forget something?

@brian-mcmaster
Copy link
Author

@rrzaripov I spent literally a half day trying to get Windows Update to install the Russian Language pack on my Win7 developer machine, and it failed. I have been unable to reproduce your issue. However, I have since fixed a nullref exception in that code, as well. Some comboboxes don't have an open button at all, so I added a null check on elementItem before logging its contents. If I find a machine with the Russian lang pack on it, i'll let you know :(

@rrzaripov
Copy link
Contributor

@brian-mcmaster thank for your work. Russian locale are not required to make test. Can you please make this test, step by step:

  1. Install CobraWinLDTP using this installer. This build contain your patch.
  2. Bring up Paint
  3. Click File | Save as... (Archivo | Guardo como)
  4. python
  5. import ldtp
  6. ldtp.getallitem("Save As", "cboSaveastype") ldtp.getallitem("Guardar como", "cboTipo")

Result is empty list or not?

@brian-mcmaster
Copy link
Author

brian-mcmaster commented Jul 13, 2016

@rrzaripov I tried and your installer failed. Why is it over 800k when my installer is only 630k? It said "the setup ended prematurely and your system was not modified". Edit: it looks like my ldtpjarfile is 0 bytes in my setups which accounts for the difference in size, I think. I still don't know why your installer doesn't work...

@brian-mcmaster
Copy link
Author

Also, as I mentioned above, you should add a check for elementItem == null on line 169, because some comboboxes don't have any buttons as a direct child and the logging statement will throw a nullref exception in those cases.

@brian-mcmaster
Copy link
Author

If you just want to send me your ldtpd.dll, I can plug it in to my build and see what happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants