HTML:
I have created a xpath
driver.find_element(By.XPATH('//h4[contains(text(),"This weekend")]'))
But every time I'm getting
TypeError: 'str' object is not callable
It seems it is not getting the xpath.
May be the xpath seems wrong.cananyone guide here
HTML:
<a class="css-t8q75u e19c3kf61" xpath="1"><div class="css-ekw2cu eh8fd9012"><div class="css-3ov7b7 eh8fd9011"><div class="css-95s8c1 eh8fd9010"><header class="css-1p61d40 eh8fd909">** are not unique
<a class="css-t8q75u e19c3kf61" xpath="1"><div class="css-ekw2cu eh8fd9012"><div class="css-3ov7b7 eh8fd9011"><div class="css-95s8c1 eh8fd9010"><header class="css-1p61d40 eh8fd909"><span class="css-m74hjb e19c3kf60"><span class="icon css-1ih0xvs e1ouvt3m1"><svg aria-label="CalendarWeekend" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" xmlns="http://www.w3.org/2000/svg" role="presentation" focusable="false" viewBox="0 0 32 32" preserveAspectRatio="xMidYMid meet" class="css-1lisf4l e1ouvt3m0"><path d="M28 14v9a5.006 5.006 0 01-4.783 4.995L23 28H9a5.006 5.006 0 01-4.995-4.783L4 23v-9h24zm-4 3h-1a1 1 0 00-1 1v1a1 1 0 001 1h1a1 1 0 001-1v-1a1 1 0 00-1-1zm-5 0h-1a1 1 0 00-1 1v1a1 1 0 001 1h1a1 1 0 001-1v-1a1 1 0 00-1-1zm3-13a1 1 0 01.993.883L23 5v1a5.006 5.006 0 014.995 4.783L28 11v1H4v-1a5.006 5.006 0 014.783-4.995L9 6V5a1 1 0 011.993-.117L11 5v1h10V5a1 1 0 011-1z"></path></svg></span></span></header><h4 class="css-11rlpdz eh8fd905">This weekend</h4><div class="css-1bu4bq eh8fd908"><h5 class="css-j3w7e9 eh8fd904">Local events taking place on Friday, Saturday and Sunday</h5></div></div></div></div></a>
Following the DeprecationWarning in selenium4 ...
DeprecationWarning: find_element_by_* commands are deprecated. Please use find_element() instead
find_element_by_*
commands are deprecated in the latest Selenium Python libraries and you have to use find_element()
instead.
To send a character sequence to the text field you can use either of the following Locator Strategies:
You need to add the following import:
from selenium.webdriver.common.by import By
Using xpath:
driver.find_element(By.XPATH, '//h4[contains(text(),"This weekend")]')