Get Value from a input field

I have an input field in a web page that I can normally set a value on it.

But when I try to get value, it returns nothing.

Is that any workaround for this problem?

Thanks

Hi @edacosta can you share the url of the web page and the input field you need to get the value from?

HI @ashapkina,

The field I was using is in a restrict area of the site, but I could reproduce the problem in this page:

URL: http://sgw.webcaravan.in/quote
Field: Company Name
Xpath: //input[@id=‘edit-company-name’]

Thanks,
Eduardo

I discovered another problem.

On Chrome the script runs but the getvalue returns empty.

On firefox and IE I can’t even run the script. I receive the following error (on setvalue and getvalue):

org.openqa.selenium.NoSuchWindowException: Unable to find element on closed window

@edacosta could you share your recording to see the details? I don’t quite understand the use case. This is the form for submitting information, so it shouldn’t have any information when you open it, then why do you use ‘Get value’?

As for the error, could you share the whole text of the error and the details of the action that fails?

Hi,

The real example is in the administration area, where I’d like to get all the content information.
All the fields are input.

But I can’t send the administration area url, because I can’t share the password.

So I reproduced the same problem in another page of the same site.

The recorder is:
import com.workfusion.studio.rpa.recorder.api.*
import com.workfusion.studio.rpa.recorder.api.types.*
import com.workfusion.studio.rpa.recorder.api.custom.*
import com.workfusion.studio.rpa.recorder.api.internal.representation.*

        def outtest = RString.of('')
        
    
        def test = RString.of('lalala')

enableTypeOnScreen()

timeouts().pageLoadTimeout(12000, java.util.concurrent.TimeUnit.MILLISECONDS)

openChrome(UrlOperations.ensureProtocol("http://sgw.webcaravan.in/quote"))
sleep(6000)


	$(byXpath("//input[@id=\'edit-company-name\']")).setValue(String.valueOf(test))
sleep(6000)


	$(byXpath("//input[@id=\'edit-name\']")).setValue(String.valueOf(test))
sleep(6000)


        outtest = RString.of($(byXpath("//input[@id=\'edit-company-name\']")).text())


openAndFocus("notepad.exe", 5000, 300)

sleep(9000)

inDesktop {

        sendKeys(StringTransformations.escapeAutoitText(outtest.toString()))

}

sleep(10000)

the error:

Error executing WebElementAction
com.workfusion.studio.rpa.recorder.playback.PlaybackException: Error executing TemplateAction[templateName=WebElementAction.ftl,id=2,name=Optional[WebElementAction],parent=1,nextSibling=3,arguments=ActionArguments[varName=[test],exactMatch=[true],xsi:type=[recorder:WebElementAction, recorder:WebElementAction],pollingInterval=[300],active=[true],searchInFrames=[false],type=[SET_VALUE],delay=[6000],useElementAttribute=[false],webElementLocatorType=[XPATH],actionDetails=[(set by //input[@id=‘edit-company-name’] xpath)],webElementLocator=[//input[@id=‘edit-company-name’]],awaitTimeout=[5000]]]
at com.workfusion.studio.rpa.recorder.playback.flow.StandardControlFlow.execute(StandardControlFlow.java:54)
at com.workfusion.studio.rpa.recorder.playback.action.template.TemplateAction.execute(TemplateAction.java:28)
at com.workfusion.studio.rpa.recorder.playback.action.template.TemplateAction.execute(TemplateAction.java:15)
at com.workfusion.studio.rpa.recorder.playback.player.ActionPlayer.next(ActionPlayer.java:53)
at com.workfusion.studio.rpa.recorder.player.PlaybackLogic.playNextAction(PlaybackLogic.java:152)
at com.workfusion.studio.rpa.recorder.player.PlaybackLogic.run(PlaybackLogic.java:112)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.openqa.selenium.NoSuchWindowException: Unable to find element on closed window
Build info: version: ‘9.0.0.4’, revision: ‘e6e278acd9’, time: ‘2018-06-19T14:40:11.651Z’
System info: host: ‘TWIN_HQ_0184’, ip: ‘192.168.0.150’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_121’
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities [{acceptInsecureCerts=false, browserVersion=11, se:ieOptions={nativeEvents=true, browserAttachTimeout=0, ie.ensureCleanSession=false, elementScrollBehavior=0, enablePersistentHover=false, ie.browserCommandLineSwitches=, ie.forceCreateProcessApi=false, requireWindowFocus=true, initialBrowserUrl=http://localhost:22141/, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000, ignoreProtectedModeSettings=false}, browserName=internet explorer, pageLoadStrategy=normal, unhandledPromptBehavior=dismiss, javascriptEnabled=true, platformName=XP, setWindowRect=true, platform=XP}]
Session ID: 0c4d744f-13bd-400d-9c01-951c18f36eba
*** Element info: {Using=xpath, value=//input[@id=‘edit-company-name’]}
Command duration or timeout: 0 milliseconds
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:41)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:82)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:45)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:656)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:426)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:528)
at org.openqa.selenium.By$ByXPath.findElement(By.java:361)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:418)
at com.workfusion.rpa.helpers.RPA.getElement(RPA.java:820)
at com.workfusion.rpa.helpers.RPA.$(RPA.java:752)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:151)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.callStatic(StaticMetaMethodSite.java:102)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:206)
at Script3.run(Script3.groovy:8)
at com.workfusion.studio.rpa.recorder.playback.shell.GroovyShellWrapper.executeScript(GroovyShellWrapper.java:90)
at com.workfusion.studio.rpa.recorder.playback.player.PlaybackContext.executeScript(PlaybackContext.java:65)
at com.workfusion.studio.rpa.recorder.playback.action.template.TemplateAction.executeBehavior(TemplateAction.java:33)
at com.workfusion.studio.rpa.recorder.playback.flow.StandardControlFlow.execute(StandardControlFlow.java:46)
at com.workfusion.studio.rpa.recorder.playback.action.template.TemplateAction.execute(TemplateAction.java:28)
at com.workfusion.studio.rpa.recorder.playback.action.template.TemplateAction.execute(TemplateAction.java:15)
at com.workfusion.studio.rpa.recorder.playback.player.ActionPlayer.next(ActionPlayer.java:53)
at com.workfusion.studio.rpa.recorder.player.PlaybackLogic.playNextAction(PlaybackLogic.java:152)
at com.workfusion.studio.rpa.recorder.player.PlaybackLogic.run(PlaybackLogic.java:112)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.openqa.selenium.NoSuchWindowException: Unable to find element on closed window
Build info: version: ‘9.0.0.4’, revision: ‘e6e278acd9’, time: ‘2018-06-19T14:40:11.651Z’
System info: host: ‘TWIN_HQ_0184’, ip: ‘192.168.0.150’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_121’
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities [{acceptInsecureCerts=false, browserVersion=11, se:ieOptions={nativeEvents=true, browserAttachTimeout=0, ie.ensureCleanSession=false, elementScrollBehavior=0, enablePersistentHover=false, ie.browserCommandLineSwitches=, ie.forceCreateProcessApi=false, requireWindowFocus=true, initialBrowserUrl=http://localhost:22141/, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000, ignoreProtectedModeSettings=false}, browserName=internet explorer, pageLoadStrategy=normal, unhandledPromptBehavior=dismiss, javascriptEnabled=true, platformName=XP, setWindowRect=true, platform=XP}]
Session ID: 0c4d744f-13bd-400d-9c01-951c18f36eba
*** Element info: {Using=xpath, value=//input[@id=‘edit-company-name’]}
Build info: version: ‘9.0.0.4’, revision: ‘e6e278acd9’, time: ‘2018-06-19T14:40:11.651Z’
System info: host: ‘TWIN_HQ_0184’, ip: ‘192.168.0.150’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_121’
Driver info: driver.version: UniversalDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:186)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:121)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:50)
at org.openqa.selenium.remote.server.ActiveSessionCommandExecutor.execute(ActiveSessionCommandExecutor.java:43)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:656)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:426)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:528)
at org.openqa.selenium.By$ByXPath.findElement(By.java:361)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:418)
at com.workfusion.universal.driver.UniversalDriver.findElement(UniversalDriver.java:80)
at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:48)
at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:33)
at org.openqa.selenium.remote.server.handler.WebDriverHandler.handle(WebDriverHandler.java:41)
at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:133)
at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:203)
at org.openqa.selenium.remote.server.InMemorySession.execute(InMemorySession.java:98)
at org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle$0(WebDriverServlet.java:231)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

@edacosta the value of the input field is not written in the html code during the execution, the value of the field is left empty, so ‘Get value’ gives you an empty string. If you need to see what is inserted in the field, you can print the value of variable ‘test’ to the notepad.

It is possible that the error is caused by incompatible drivers.

What version of RPA Express do you use?
You can see it in Control panel.

What are the versions of IE and Firefox?

@ashapkina,

I understand what you say, but this is not the real problem.

The page I’m trying to get this information loads all the input field with their values stored in the database.

I’ll try to reproduce in a better way.

And the error? Why I’ve got this error?

Thanks

Sorry. I saw you answer after asking about the error. I’ll check the versions

If you cannot share the url, could you share the source code of the input field then?

The versions:

RPA Express 2.0.3 com.workfusion.studio.express.feature.feature.group WorkFusion Inc.
WorkFusion Studio 2.0.3 com.workfusion.studio.express.product null
Recorder 2.0.3 com.workfusion.studio.recorder.feature.feature.group WorkFusion Inc.

Internet explorer: 11.0.9600.19100
Firefox portable: 46.0.1 (I haven’t updated the .bat files because I didn’t found them)

The element: //*[@id=“edit-title-0-value”]

HTML:
input class=“js-text-full text-full form-text required” data-drupal-selector=“edit-title-0-value” type=“text” id=“edit-title-0-value” name=“title[0][value]” value=“Shakespeare’s Birthplace” size=“60” maxlength=“255” placeholder="" required=“required” aria-required=“true”

The xpath is working, because I test the setvalue and it worked. Only the getvalue that returns blank.

Thanks

Is this the value you need to get?

@edacosta try updating the browser to the current versions.

Yes, this one.

value=“Shakespeare’s Birthplace”

Try using the attribute ‘value’ in the Web element action

Thanks @ashapkina!

I haven’t noticed this field attribute. I’ll test later.

Thanks for your patience and congratulations for your prompt answers!

@edacosta you’re welcome :slightly_smiling_face: Let me know if this option helps