Coder Social home page Coder Social logo

ldtp / cobra Goto Github PK

View Code? Open in Web Editor NEW
111.0 24.0 51.0 1.06 MB

Windows version of Linux Desktop Testing Project

C# 70.91% Java 14.63% Perl 1.71% Python 9.96% Ruby 2.00% Makefile 0.03% PowerShell 0.23% Visual Basic 0.21% Batchfile 0.10% Perl 6 0.21%

cobra's Issues

Fault on enterstring('<')

Hi,

I'm getting an error when calling ldtp.enterstring(<window>, <field>, '<'):

>>> import ldtp
>>> ldtp.enterstring('frmUntitled - Notepad', 'txt0', '<')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files (x86)\VMware\CobraWinLDTP\ldtp\__init__.py", line 432, in enterstring
    return _remote_enterstring(window_name, object_name, data)
  File "C:\Program Files (x86)\VMware\CobraWinLDTP\ldtp\client.py", line 72, in __call__
    return self.__send(self.__name, args)
  File "C:\Python27\lib\xmlrpclib.py", line 1599, in __request
    verbose=self.__verbose
  File "C:\Program Files (x86)\VMware\CobraWinLDTP\ldtp\client.py", line 195, in request
    raise e
xmlrpclib.Fault: <Fault 0: 'Index was outside the bounds of the array.'>

Here are request_body and payload:

(Pdb) payload
'<?xml version="1.0"?>\r\n<methodResponse>\r\n  <fault>\r\n    <value>\r\n      <struct>\r\n        <member>\r\n          <name>faultCode</name>\r\n          <value>\r\n            <i4>0</i4>\r\n          </value>\r\n        </member>\r\n        <member>\r\n          <name>faultString</name>\r\n          <value>\r\n            <string>Index was outside the bounds of the array.</string>\r\n          </value>\r\n        </member>\r\n      </struct>\r\n    </value>\r\n  </fault>\r\n</methodResponse>'
(Pdb) request_body
"<?xml version='1.0'?>\n<methodCall>\n<methodName>enterstring</methodName>\n<params>\n<param>\n<value><string>frmUntitled - Notepad</string></value>\n</param>\n<param>\n<value><string>txt0</string></value>\n</param>\n<param>\n<value><string>&lt;</string></value>\n</param>\n</params>\n</methodCall>\n"
(Pdb) 

Is there a way to fix it or workaround it?

I've tried using settextvalue and inserttext, both have no effect but still return 1...

Get Context Menu for Internet Explorer

I tried the following script to get to the context menu of Internet Explorer when you click the Tools Icon (Gear Like Icon).
image

This is the target i wanted to click.
image

However upon using Visual Automation Verify I noticed the context menu is not under the IE Window but instead it is under the Desktop Pane of the OS itself.
image

So I resorted to making my Window to '*' to catch all Windows.

Here's my code:

from ldtp import *

click ('*Internet Explorer', 'Tools')
selectmenuitem('*', 'Context;Internet Options')

This is the version of IE im using:
image

For my script I get the following Error:

Traceback (most recent call last):
  File "D:/Projects/SandBox/configurator/configurator/base/base.py", line 7, in <module>
    selectmenuitem('*', 'Internet Options')
  File "C:\Program Files (x86)\VMware\CobraWinLDTP\ldtp\client.py", line 72, in __call__
    return self.__send(self.__name, args)
  File "C:\Python27\lib\xmlrpclib.py", line 1578, in __request
    verbose=self.__verbose
  File "C:\Program Files (x86)\VMware\CobraWinLDTP\ldtp\client.py", line 193, in request
    raise LdtpExecutionError(e.faultString.encode('utf-8'))
ldtp.client_exception.LdtpExecutionError: Unable to find Object: Internet Options

Any suggestions?

C#: Need some assistance converting the following Python code to C#

Hi guys, I somehow got the previous issue #7 to work. Now I'm having some issues writing the same script in C#.

The problem is once again on how to make sure the object is detected. Here's what I've made so far that builds and works. Only up to that point.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Ldtp;
using Ldtpd;

namespace ldtp.test.ie
{
    class Program
    {
        static void Main(string[] args)
        {
            // Indicate arguments here.
            string[] s1 = new string[1] {""};

            Ldtp.Ldtp l = new Ldtp.Ldtp("*Internet Explorer");
            l.LaunchApp("iexplore", s1); // requires arguments by default. this should be optional.
            l.WaitTillGuiExist();
            l.Click("Tools");
            l.WaitTime(1);

        }
    }
}

The following script does not work when appended:

l.SelectMenuItem("mnuContext");

Any suggestions?

Slider (QSlider) getvalue throws "Unable to get value"

Hello,
I have a Windows Qt application with a horizontal QSlider. I'm trying to interact with it using LDTP's getvalue, increase, decrease, etc functions. All these functions give me error "Unable to get value".

I have also push buttons and check boxes which I'm able to interact with using LDTP.

My Qt version is 5.6 beta, VS2015. Windows 10.

Here's the whole error:
Traceback (most recent call last):
File "test.py", line 8, in
getvalue('MainWindow', 'sldr0')
File "C:\Program Files (x86)\VMware\CobraWinLDTP\ldtp\client.py", line 72, in call
return self.__send(self.__name, args)
File "C:\Python27\lib\xmlrpclib.py", line 1599, in __request
verbose=self.__verbose
File "C:\Program Files (x86)\VMware\CobraWinLDTP\ldtp\client.py", line 193, in request
raise LdtpExecutionError(e.faultString.encode('utf-8'))
ldtp.client_exception.LdtpExecutionError: Unable to get value

Need to escape '|' pipe characters in regex matches on Windows

Just ran into another issue with LDTP here at Tableau Software. We use pipe characters to delimit our Pseudoloc strings, so and example string looks like this: "23153-|Blah|"

This causes problems because the pipe characters don't get escaped in the internal regex matches in Utils.cs, so it considers the '|' characters to be 'or'. And since the string ENDS in a pipe character, it matches any control with a caption of empty string, which is really bad.

It's an easy fix, just have to escape the pipe characters in line 144 of ldtpd\Utils.cs and make them be '|' just like the rest of the escapes. In addition, I had to add this around line 626 in the same file:
tmp = Regex.Replace(tmp, @"|", @"|");

I haven't tested this on other non-Windows platforms yet.

Thanks,
Brian McMaster
Principal Software Test Engineer
Tableau Software (http://www.tableau.com)

Python bindings missing common functions?

A number of methods I use in Python don't show up as autocomplete suggestions, and I think it's because they're not present in the init.py bindings.
For example, click(), selectrowindex(), and mousemove() are all absent.

Is this intentional, or would submitting a PR to add some more methods be useful?
Also, suggestions about how I might determine what methods should and shouldn't be added if I wanted to do that?

LDTP_DEBUG=0

At http://ldtp.freedesktop.org/wiki/FAQ/ it's mentioned:

  • Use export LDTP_DEBUG=1 to get messages in console
  • Use export LDTP_DEBUG=2 to get verbose messages in console

Wouldn't it make sense then that LDTP_DEBUG=0 would mean no debugging ? The current code seem to only check if the variable exists, not what it's set to.

Import issues with Python 3

With Python 2.7.10 I can simply write import ldtp and things work fine.
However, with Python 3.3.5 and 3.4.3 (the versions I tested) I have to manually launch CobraWinLDTP.exe before I import, otherwise it gives me the following error:

Traceback (most recent call last):
  File "C:\Program Files (x86)\VMware\CobraWinLDTP\ldtp\client.py", line 144, in request
    h=self.send_request(host, handler, request_body, bool(verbose))
  File "C:\Users\jsleeper\Documents\Git repos\test_framework\tools\Python3\lib\xmlrpc\client.py", line 1264, in send_request
    self.send_content(connection, request_body)
  File "C:\Users\jsleeper\Documents\Git repos\test_framework\tools\Python3\lib\xmlrpc\client.py", line 1294, in send_content
    connection.endheaders(request_body)
  File "C:\Users\jsleeper\Documents\Git repos\test_framework\tools\Python3\lib\http\client.py", line 1084, in endheaders
    self._send_output(message_body)
  File "C:\Users\jsleeper\Documents\Git repos\test_framework\tools\Python3\lib\http\client.py", line 922, in _send_output
    self.send(msg)
  File "C:\Users\jsleeper\Documents\Git repos\test_framework\tools\Python3\lib\http\client.py", line 857, in send
    self.connect()
  File "C:\Users\jsleeper\Documents\Git repos\test_framework\tools\Python3\lib\http\client.py", line 834, in connect
    self.timeout, self.source_address)
  File "C:\Users\jsleeper\Documents\Git repos\test_framework\tools\Python3\lib\socket.py", line 512, in create_connection
    raise err
  File "C:\Users\jsleeper\Documents\Git repos\test_framework\tools\Python3\lib\socket.py", line 503, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "C:\Users\jsleeper\Documents\Git repos\test_framework\tools\Python3\lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\jsleeper\Documents\Git repos\test_framework\tools\Python3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\jsleeper\Documents\Git repos\test_framework\tools\Python3\Scripts\behave.exe\__main__.py", line 9, in <module>
  File "C:\Users\jsleeper\Documents\Git repos\test_framework\tools\Python3\lib\site-packages\behave\__main__.py", line 109, in main
    failed = runner.run()
  File "C:\Users\jsleeper\Documents\Git repos\test_framework\tools\Python3\lib\site-packages\behave\runner.py", line 707, in run
    return self.run_with_paths()
  File "C:\Users\jsleeper\Documents\Git repos\test_framework\tools\Python3\lib\site-packages\behave\runner.py", line 712, in run_with_paths
    self.load_hooks()
  File "C:\Users\jsleeper\Documents\Git repos\test_framework\tools\Python3\lib\site-packages\behave\runner.py", line 631, in load_hooks
    exec_file(hooks_path, self.hooks)
  File "C:\Users\jsleeper\Documents\Git repos\test_framework\tools\Python3\lib\site-packages\behave\runner.py", line 304, in exec_file
    exec(code, globals, locals)
  File "features\environment.py", line 5, in <module>
    from device_manager.device_management import DeviceManager
  File "C:\Users\jsleeper\Documents\Git repos\test_framework\device_manager\device_management.py", line 7, in <module>
    import ldtp
  File "C:\Program Files (x86)\VMware\CobraWinLDTP\ldtp\__init__.py", line 598, in <module>
    _populateNamespace(globals())
  File "C:\Program Files (x86)\VMware\CobraWinLDTP\ldtp\__init__.py", line 243, in _populateNamespace
    for method in client._client.system.listMethods():
  File "C:\Users\jsleeper\Documents\Git repos\test_framework\tools\Python3\lib\xmlrpc\client.py", line 1098, in __call__
    return self.__send(self.__name, args)
  File "C:\Users\jsleeper\Documents\Git repos\test_framework\tools\Python3\lib\xmlrpc\client.py", line 1437, in __request
    verbose=self.__verbose
  File "C:\Program Files (x86)\VMware\CobraWinLDTP\ldtp\client.py", line 159, in request
    if ((_ldtp_windows_env and e[0] == 10061) or \
TypeError: 'ConnectionRefusedError' object is not subscriptable

For the record I'm only using LDTP locally right now.
Suggestions?

C# ldtp Object LaunchApp method requires arguments by default.

The following piece of code required some arguments by default.

namespace ldtp.test.ie
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s1 = new string[1] {""}; // requires arguments by default. this should be optional.
            Ldtp.Ldtp l = new Ldtp.Ldtp("*Internet Explorer");
            l.LaunchApp("iexplore", s1); // requires arguments by default. this should be optional.
        }
    }
}

I was hoping if it's possible to remove the requirement for arguments because not all applications require arguments on start.

ComboBox.GetAllItems fails on non-English Windows OS

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);

Can't read text from QTextBrowser

In a Qt app if there is a QTextBrowser element it's detected as a label by ldtp, it has type ControlType.Text.

However if I try to call ldtp.gettextvalue('window', 'lbl0') I get "Unable to find object: lbl0" since Text.cs does not include ControlType.Textamong it's candidates in Text::GetObjectHandle(). I added it there and recompiled and then I got the text value that I needed.

I am unsure if that is the proper fix though, should this type have been detected as something else ?

But otherwise it's a simple fix that solves my problem.

TypeError for getwindowlist()

I got this in 4.0.0 when calling getwindowlist(), the call worked after commenting out that logger call.

>>> from ldtp import *
>>> getwindowlist()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files (x86)\VMware\CobraWinLDTP\ldtp\client.py", line 71, in
__call__
    for k, v in kwargs.items()])))
TypeError: unsupported operand type(s) for +: 'map' and 'list'

Help with build and package instructions?

I'm trying to build cobra from source to see if I can get improved Python 3 support (the latest official release, 4.0.0, doesn't auto-start the service like it does with Python 2.7) but having some trouble following the provided instructions.

I've downloaded Visual Studio 2015 CE and built the SetEnvironmentVariable and CobraWinLdtp solutions, but I'm not sure where to go next. The build and package instructions simply say

... place the binary where you have all the dll's, README.txt, License.rtf, before running Wix installer commands.

but I'm not sure which binary (I'm guessing it might be referring to "..\CobraWinLdtp\bin\Debug\CobraWinLdtp.exe" that I just built?)
I'm also unsure what or where "all the dll's" are, or if I'm supposed to move README.txt and License.rtf, or copy things into where they are.

If you can guide my hand a bit here I'd be happy to submit a PR to clean up the existing instructions.
Also for the record I'm using Visual Studio 2015 CE on Windows 10 Professional 64-bit.

Thanks!

Unable to access FlowDocument UI elements

Hi Team,

We are using LDTP for automating our windows application, Most of the window are implemented in WPF visual tree but one part of the window is implemented as FlowDocument.

LDTP is able to identify all the UI elements except window elements implemented in FlowDocument.

Is there way in LDTP to access FlowDocument UI elements?

Thanks,
vraj

No file 'ldtp.jar'

I am trying to build the Ldtp.
VS 2015.

I have received the error:

D:\cobra-master\CobraWinLDTP.Wix\CobraWinLDTP.wxs(401): error LGHT0103: The system cannot find
the file '..\CobraWinLDTP\ldtp\ldtp.jar'. [D:\cobra-master\CobraWinLDTP.Wix\CobraWinLDTP.Wix.cs
proj]

How I can fix it and build the solution?

Cannot get the state 'isreadonly' of a textbox

Hi,

I'm trying to got the state of a textbox but now it can only support 'visible, showing, enabled'. I need to check if a textbox is readonly. Could you help to fix that or provide a workaround?

thanks
Leo

4.0 is broken on Win10

Is this project alive and well? It looks abandoned to me but correct me if I am wrong. Anyhow. Windows 10 x64 got the client running despite the lacking instructions on how to. So it now listens and ldtp gets imported correctly however the moment the first command is issued it looks like a protocol violation to me.

# python
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ldtp
>>> ldtp.launchapp('notepad')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files (x86)\VMware\CobraWinLDTP\ldtp\__init__.py", line 416, in launchapp
    return _remote_launchapp(cmd, args, delay, env, lang)
  File "C:\Program Files (x86)\VMware\CobraWinLDTP\ldtp\client.py", line 71, in __call__
    for k, v in kwargs.items()])))
TypeError: unsupported operand type(s) for +: 'map' and 'list'

Object reference not set to an instance of an object

While working on #15 I noticed the error in the title of this issue when I built from master. The latest binary using installer 4.0.0 did not show that error.

This happens when I do a call to: ldtp.selectitem(...).

I ran a bisect and got this:

There are only 'skip'ped commits left to test.
The first bad commit could be any of:
3a912d3
ef33a26
99732f5
We cannot bisect more!

Two of those commits didn't build that's why it only narrowed it down to three.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.