RanorexDriver problems with Selenium exceptions

leharn01
Posts: 3
Joined: Tue Feb 21, 2023 3:13 pm

RanorexDriver problems with Selenium exceptions

Post by leharn01 » Wed Feb 22, 2023 7:27 am

Hi,
In our company, we exclusively use the RanorexDriver with Python to script our test cases. We have always used a pre-release version of 9.3.2. Recently, we attempted to update to the latest version (10.2.2). Unfortunately, we encountered some strange bugs in this version, including one that completely breaks the functionality of the driver.
Whenever a Selenium exception is raised, such as a "NoSuchElementException," the RanorexDriver sends the message back in the wrong format, causing the Selenium ErrorHandler to be unable to decode the message. As a result, instead of the expected error, a KeyError is raised:

File "C:?\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:?\Python\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 130, in check_response
status = value["status"]
~~~~~^^^^^^^^^^
KeyError: 'status'

Value is the following:
{'sessionId': '36d8e417a84d49059d4967d6092be724', 'value': {'error': 'no such element', 'message': "Element with selector '/form[@title='']//text[@caption>'Möchten Sie Ihre letzte Sitzung']' was not found (within 2000ms).", 'stacktrace': ' bei System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)\r\n bei System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)\r\n bei System.Windows.Forms.Control.Invoke(Delegate method)\r\n bei RanorexDriver.Sta.Call[T](Func`1 func)\r\n bei RanorexDriver.RanorexDriverImpl.FindElement(String fromElementId, WebDriverFindBy by)\r\n bei RanorexDriver.Server.WebDriverController.<>c__DisplayClass18_0.<FindElement>b__0(WebDriverSession s)\r\n bei RanorexDriver.Server.Wd.TryWithSession(Func`2 func, String sid)'}}

We have attempted to resolve this issue with both a fresh install of Selenium 3.14 and Selenium 4, but encountered this error in both situations. We also tried multiple versions of python from 3.7 onwards, as well as multiple RanorexDriver versions. The only working Version is 9.3.2. This problem renders the product completely unusable for us in its current state. Is there a way to fix this issue, without modifying the error handler of Selenium?
Additionally, switching to using the Studio is not feasible for us due to the extensive library of previously created and coded test cases.
Thanks for any help!

leharn01
Posts: 3
Joined: Tue Feb 21, 2023 3:13 pm

Re: RanorexDriver problems with Selenium exceptions

Post by leharn01 » Thu Mar 16, 2023 1:12 pm

Hi,

I just wanted to post a quick follow-up. We managed to find a workaround for the stated problem. The Ranorex Driver sends a response that adds an additional JSON key 'sessionId'. In the check_response method of Selenium, it checks for the number of keys in the response. It expects there to be only one key, namely 'value'. So, to fix the problem, you need to pop the 'sessionId' key from the error response before the len(value.keys()) check from Selenium starts.

Unfortunately, after we found the solution to the problem, we discovered additional bugs. If you already created a WebElement, you cannot use the .find_elements or .find_elements_by_xpath method on the Webelement. The RanorexDriver flat out responds that it doesn't know which method to use in that case. If you use .find_element() or .find_element_by_xpath, on an existing it works.

The second bug is that you can't use .get_attribute() on any element because scripting is disabled.

Both of these functions were working in version 9.3.2.
Additionally, there is no workaround for these two new bugs.