1

I have already been through various threads here on SO but it hasn't worked for me so far.

I am using the following code:

from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
xPathFull = r'/html/body/div[2]/div[2]/div[1]/div[1]/div/form/div[2]/div[2]/input'
path_to_chromedriver = r'C:\chromedriver'  # change path as needed
browser = webdriver.Chrome(executable_path=path_to_chromedriver)
.........
.........
content = browser.find_element_by_xpath(xPathFull).text

The html of the location I am trying copy text from is:

<input name="shortLink" type="text" value="https://shrsl.com/2dsda" onfocus="this.select();" readonly="">

Basically I want the content variable above to store the value https://shrsl.com/2dsda

1 Answer 1

3

Try:

content = browser.find_element_by_xpath(xPathFull).get_attribute('value')
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.