0

I am scraping information from a webpage. The following is a snippet of the Javascript function that I am looking to extract the return string value from. In this case "2227885"

enter image description here

I have used the following method from selenium to attempt to extract this value:

result = driver.execute_script("getCurrentClientId()[0]")
print(result)

However, the value returned is None. What is the proper solution to extract the return value from this JS function?

2 Answers 2

1

use "return" as part of your javascript:

result = driver.execute_script("return getCurrentClientId()[0]")
print(result)
Sign up to request clarification or add additional context in comments.

Comments

0
result = driver.execute_script("return getCurrentClientId()")
print(result)

if the function is not within the html source ,and you want to pass explicitly then use

result = driver.execute_script("return arguments[0]", getCurrentClientId)
print(result)

what ever we pass to execute_script will be passed into arguments arraay in the same order. so the getCurrentClientId can be accessed in the script as arguments[0]

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.