Entering text to span Selenium/Python

Question:

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")

Asked By: MichalG

||

Answers:

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)
Answered By: iamsankalp89
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.