Search code examples
javaswingjruby

Script plugging in value, then it later disappears


I have a script in Marathon, a Java Swing test automation tool using Jython or JRuby, that plugs in a value to the application under test; however, it doesn't plug it in sometimes. It is very sporadic. I tried to wrap the setting of the text values with an until loop, but that even sometimes doesn't work. The code looks like this:

until get_component("foo").getText() == "blah" do
    select("foo", "blah")
end

get_component("") is a function that returns the Java object. After that I'm pretty much doing straight Java so the .getText() works just as it would in Java. Select is also a Marathon function that simply selects your foo object and plugs in the blah value. Therefore, all my code is doing is waiting until the "foo" object has "blah" text value and once it does then it moves on.

The problem that I have is that sometimes the application doesn't hold the "blah" value. I considered that it was a bug, but when I do this manually I can't recreate the problem. It simply plugs in the value as I would expect it to.

Has anybody else ever ran into this with any other scripting tool? If so, how did you overcome it?


Solution

  • I was able to get around this by putting a wait_p("foo", "blah") immediately after select("foo", "blah")

    select("foo", "blah")
    wait_p("foo", "blah")
    

    This basically forces the application to wait until the foo component has the blah text before moving on.