MichalG
MichalG

Reputation: 371

Entering text to span Selenium/Python

I try to enter text to span in place of "SAMPLE TEXT". I'm using Selenium/Python but I can't do it using send_keys method. Do you have any other ideas how can I do that? I attached screenshots with HTML and screenshot from app

enter image description here

enter image description here

I tried to use that code, but doesnt work:

body = driver.find_element_by_xpath('//*[@id="oss-view-wrapper"]/main/div/div/div[2]/div/div[2]/div[1]/div/div/div[2]/div/div/div[2]/div/div[2]/div[2]/div/div/div/div[2]/div/div/div/div/div/div[6]/div[1]/div/div/div/div[5]/div/pre/span')
body.send_keys("TEST")

Upvotes: 2

Views: 5433

Answers (1)

iamsankalp89
iamsankalp89

Reputation: 4739

You can use javasecriptExceutor for that, Please chech code at once i am not have deep knowledge of Python:

element = driver.find_element_by_xpath('Your xpath')
driver.execute_script("arguments[0].innerText = 'test'", element)

Upvotes: 4

Related Questions