[Solved] How to locate an element and extract required text with Selenium and Python


You can use

driver.find_element_by_css_selector('.form-control + [for=address]').text

Use replace() to remove the enter this code: string if required

That is a class selector “.” with adjacent sibling combinator joining to attribute = value selector. So element with attribute for having value address that is adjacent to element with class form-control.

solved How to locate an element and extract required text with Selenium and Python