You can return values ββeven if you donβt have a piece of code written as a function, as in the code example below, simply by adding return var; at the end, where var is the variable you want to return.
result = driver.execute_script('''cells = document.querySelectorAll('a'); URLs = [] console.log(cells); [].forEach.call(cells, function (el) { if(el.text.indexOf("download") !== -1){ //el.click(); console.log(el.href) //window.open(el.href, '_blank'); URLs.push(el.href) } }); return URLs''')
result will contain an array that is in the URLs this case.
Eduard Florinescu Dec 28 '17 at 12:46 on 2017-12-28 12:46
source share