0

I am using robotframework to perform web automation using IE11 and seleniumlibrary. It runs on windows 10 workstations. I use IE driver 3.14.0 32-bit as it allows to run scripts when screen is locked.

I am getting lot of Invalid selector exceptions with reason [object Error] which results in tests to fail. The selectors work well sometimes and fail after some time. Is it something with the library versions? The driver exists in the project root folder and all required IE settings are available.

Packages used:

  • selenium 3.141.0
  • robotframework 3.2.1
  • rf-seleniumlibrary 4.4.0

I am providing the elements as variables to robot through a file. eg: home='''//a[@href="http://example.com/example/example?abc=Home"]'''

Sample error:

InvalidSelectorException: Message: Unable to locate an element with the xpath expression //a[@href="http://example.com/example/example?abc=Home"] because of the following error:
[object Error]
  • 1
    What I have experience with, it mostly relates to a waiting strategy. The frontend is a turbuletn place and some elements take a while to get displayed, get usable, ... If this is not handled in your RF scripts, you'll encounter such problems. – pavelsaman Sep 26 at 18:12
  • Thanks for your comment @pavelsaman. I do have waiting strategy enabled . But for eg: The get element count keyword in seleniumlibrary, as per doc it is supposed to return an integer. So if the element is not found it should return 0. But sometimes, it gives me [object error] and fails. when i re-run the test , it works fine. I am not sure if this is something with IE. – rovaru Sep 26 at 18:41
  • Could you provide an example of your code? – pavelsaman Sep 27 at 10:59
  • @pavelsaman ` *** Settings *** Library SeleniumLibrary Library Collections Library String Variables variables.py *** Test Cases *** My_Test Open browser example.com ie Maximize Browser Window ${home_count}= Get Element Count ${home} Run keyword if ${home_count}>0 Press Key ${home} \\13 ` – rovaru Sep 27 at 17:56
0

I'll first copy and format your piece of code you posted in the comment section:

*** Settings *** 
Library    SeleniumLibrary 
Library    Collections 
Library    String
Variables     variables.py 

*** Test Cases *** 
My_Test 
    Open browser    example.com   ie 
    Maximize Browser Window 
    ${home_count}=    Get Element Count    ${home} 
    Run keyword if    ${home_count}>0 
    Press Key    ${home}

I asked you about a waiting strategy. What I meant by it is that when this keyword ${home_count}= Get Element Count ${home} gets executed, you never know if the page/elements are already present on the page. That's why in Selenium/RF there're keywords such as Wait Until Elements Is Visible etc.

So, when you actually use a waiting strategy, what happens?

*** Test Cases *** 
My_Test 
    Open browser    example.com   ie 
    Maximize Browser Window 
    Wait Until Element Is Visible    ${home}
    ${home_count}=    Get Element Count    ${home} 
    Run keyword if    ${home_count}>0 
    Press Key    ${home}
| improve this answer | |
  • Sorry for not formatting the code. I did have a wait with wait until page contains element keyword, with 20 sec timeout. In that case as well, the wait keyword fails, at times, with [Object Error] as reason. The actual fail message is in my main post. When this error occurs, the script immediately fails. ie, it doesn't wait for the timeout value to finish. i could see the element visible and available on the page. If it was an element not found issue, then I think an appropriate error message would have thrown. When I rerun the script, it ll run fine. – rovaru Sep 27 at 18:23
  • I see, than I'm only able to offer a general piece of advice: check version (IE, driver) compatibility, check other logs if there're some, IE settings (some other internet discussions say something about security settings you need to change in order to use it with the driver for automation). If you say the script works sometimes, I feel like the problem will be outside the script, but perhaps that's only my assumption based on the impression from this question. – pavelsaman Sep 27 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.