All you have to do is:
Object val = js.executeScript("return returnFoo();");
That will give you what you are looking for.
More Related Contents:
- Ways to deal with #document under iframe
- org.openqa.selenium.ElementNotInteractableException: Element is not reachable by keyboard: while sending text to FirstName field in Facebook
- WebDriver click() vs JavaScript click()
- Is there a way to get element by XPath using JavaScript in Selenium WebDriver?
- Execute JavaScript using Selenium WebDriver in C#
- Getting the return value of Javascript code in Selenium
- Element not visible error (not able to click an element)
- Unable to sign into google with selenium automation because of “This browser or app may not be secure.”
- Selenium Datepicker using JavascriptExecutor
- Scrolling to top of the page in Python using Selenium
- In protractor, browser.isElementPresent vs element.isPresent vs element.isElementPresent
- Understanding execute async script in Selenium
- Set value of input instead of sendKeys() – Selenium WebDriver nodejs
- Custom browser actions in Protractor
- Take elements while a condition evaluates to true (extending ElementArrayFinder)
- What does arguments[0] and arguments[1] mean when using executeScript method from JavascriptExecutor interface through Selenium WebDriver?
- Accessing elements in the shadow DOM
- An error has occured in ‘site url’: Uncaught TypeError: Cannot read property ‘getColomnSet’ of undefined with Selenium and Python
- What is JavaScriptExecutor in Selenium?
- scrollIntoView vs moveToElement
- Opening a new tab using Ctrl + click combination in Selenium Webdriver
- Disable images in Selenium Python
- Using cross-platform keyboard shortcuts in end-to-end testing
- Official locator strategies for the webdriver
- Can a website detect when you are using Selenium with chromedriver?
- Selenium WebDriver JS – Explicit Wait
- Selenium: Scroll to end of page in dynamically loading webpage
- How to disable Javascript when using Selenium?
- How do I load a javascript file into the DOM using selenium?
- org.openqa.selenium.UnhandledAlertException: unexpected alert open