How to put text in between a paragraph <p></p> tag on python/selenium?

0

Issue

I’m testing some automation on a website and I encountered a <p> tag inside an iframe. I need to populate some text specifically between the <p></p> tags.

I’ve already tried using .text() = 'some text' but it does not work
I’ve also tried doing .text('some text') with no success

I was just recently initiated into python and selenium so this is really hard to figure out for some reason

Python Code

from selenium import webdriver
browser.get('www.somewebsite.com')
iframe = browser.find_element_by_id('IFR1')
browser.switch_to.frame(iframe)
browser.find_element_by_tag_name("p").text() = 'this is a txt test'
print('success')

I expect the <p> tag to have ‘this is a txt text’ but nothing happens

Solution

After a lot of trial and error I was able to use ActionChains(browser).send_keys('this is a test').perform() in order to achieve writing some text inside the tags

Answered By – quality InterAct

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More