I am attempting to run a selenium script which will return the text displayed on the screen after a user input into a dynamic search field.
I am able to enter the text and see the results on screen but my Javascript to output the text does not work as the ID field I am using is dynamic.
I am trying to get the text to display in the Browser Console so I can use that in my Javascript. If I try by ID but use the dynamically assigned ID then I get the appropriate return, however, the next time the page refreshes that ID will no longer be valid.
The HTML is as follows:
<input 
    type="text" 
    id="origin-29890" 
    name="origin" 
    class="ej-input origin ui-autocomplete-input" 
    required="" 
    aria-label="From Airport" 
    data-routesearch-placeholder="e.g. London Gatwick" 
    aria-describedby="route-search-origin-description" 
    aria-autocomplete="list" 
    aria-expanded="false" 
    autocomplete="off" 
    aria-owns="ui-id-1" 
    placeholder="e.g. London Gatwick" 
    aria-activedescendant="selected-autocomplete-item">
If I try to use getElementsByClassName instead then on running that in the browser console I don't get what I'm looking for;
"f values() { [native code] }
If the field was static then the following would work
String script = "return document.getElementById(\"origin\").value";
String text= (String) jse.executeScript(script);
System.out.println(text);
I'm looking for a way of either changing the return document line to use a dynamic id or showever make the script accept the Xpath so I can include a starts with tag