Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98819

How to access returned JavaScript promise value in selenium?

$
0
0

I'm trying to access promise value which I return from JavaScript function. When I try to return it in selenium it returns None. My function works and I can print responseData in console.log. I just struggle with accessing it in python. Is there any way to do it ?

   js_value = self.driver.execute_script("""
    var request = "";
        async function final(){
            await send("POST", "https://www.thecrims.com/login",data).then((responseData)=>{
                request = responseData
            });
        };
return request;

""")
    time.sleep(3)
    print(js_value)

Viewing all articles
Browse latest Browse all 98819

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>