0

I'm trying to send a command to the JavaScript console with Selenium, but it keeps returning None

    driver.execute_script('ScavengeScreen')

If I enter 'ScavengeScreen' into the Firefox console I get an object back.

firefox console

More info of the 'ScavengeScreen' JavaScript:

<script>
    $(function() {
        Timing.whenReady(function() {
            require(['Modules/ScavengeScreen/ScavengeScreen'], function(ScavengeScreen) {
                var data = {...some json data...};

                if (window.hasOwnProperty('ScavengingOverview') && window.ScavengingOverview.data_data.hasOwnProperty(data.data_id)) {
                    data = window.ScavengingOverview.data_data[data.data_id];
                }

                var screen = new ScavengeScreen(...some json data...);
                screen.init();
                window.ScavengeScreen = screen;
                screen.updateInputs();
            });
        });
    });
</script>

How do I get the same result in Selenium?

3
  • 1
    can you link me the site please? Commented Jul 14, 2020 at 18:04
  • 1
    try adding return as the first script statement so that the line would be driver.execute_script('return ScavengeScreen;') Commented Jul 14, 2020 at 18:07
  • @AleksanderIkleiw I'm sorry but the site is behind a paywall. But I can post more info if needed. Commented Jul 14, 2020 at 18:08

1 Answer 1

3

Change driver.execute_script('ScavengeScreen') to driver.execute_script('return ScavengeScreen;').

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.