onChange java script function

i getting below error

org.openqa.selenium.WebDriverException: unknown error: Runtime.evaluate threw exception: SyntaxError: Invalid or unexpected token

(Session info: chrome=68.0.3440.106)

(Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 10.0.16299 x86_64) (WARNING: The server did not provide any stacktrace information)

Command duration or timeout: 0 milliseconds

Build info: version: ‘3.7.1’, revision: ‘8a0099a’, time: ‘2017-11-06T21:07:36.161Z’

System info: host: ‘L10-5CG8155PHV’, ip: ‘172.20.65.250’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_181’

Driver info: com.kms.katalon.selenium.driver.CChromeDriver

Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.35.528161 (5b82f2d2aae0ca…, userDataDir: C:\Users\xsivaru\AppData\Lo…}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 68.0.3440.106, webStorageEnabled: true}

Session ID: 5f55f0eca696c336614d0ead5a82d202

My code :

WebDriver driver = DriverFactory.getWebDriver()

WebElement c = driver.findElement(By.xpath(‘//*[@id=“mobile”]’))

((JavascriptExecutor) DriverFactory.getWebDriver()).executeScript(“showMobileProductInfo()=” + device + “”,c)

This…

"showMobileProductInfo()=" + device + ""

is not a legal JavaScript assignment expression. You are trying to assign the value of device to the result a call to a function, which is not possible (or even sensible).

In addition, you’ll find it easier to use webUI.executeJavaScript.

Finally, what does this have to do with onchange?

Hi Russ
thanks for the answer…

i tried webUI.executeJavaScript. but i got the error

This is my code:

WebElement element = WebUiCommonHelper.findWebElement(findTestObject(‘Sale/BindingPeriod’), 30)

WebUI.executeJavaScript(‘getAdditions(); getDeviceListPrice();’, element)

Error:

Test Cases/SE_DSL_Consumer FAILED because (of) groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.executeJavaScript() is applicable for argument types: (java.lang.String, org.openqa.selenium.remote.RemoteWebElement) values: [getAdditions(); getDeviceListPrice();, [[CChromeDriver: chrome on XP (8ed90f1de16586732ff81a7fb02083c8)] -> xpath: //*[@class = ‘shortoptions’ and @name = ‘bindingPeriod’ and @id = ‘bindingPeriod’]]]

Possible solutions: executeJavaScript(java.lang.String, java.util.List), executeJavaScript(java.lang.String, java.util.List, com.kms.katalon.core.model.FailureHandling)

The second argument to executeJavaScript must be a list:

WebUI.executeJavaScript(‘getAdditions(); getDeviceListPrice();’, Arrays.asList(element))

image.png