I need another tip today. I'm trying to build Python/Selenium code with the idea of clicking on www.thewebsiteIwantoclickon Below is an example of the HTML I'm working on.
Classentity-result__title-text is repeated multiple times in HTML, so I want to click the element href=## for each class entity-result__title-text # Open the website www.thewebsiteIwantoclickon Perform some actions (I did it in separate code) and go back to the previous HTML and repeat the same process until the last class Entity-Result__TitleText
<span class="entity-result__title-text t-16"> <a class="app-aware-link " href="https://www.thewebsiteIwantoclickon" data- test-app-aware-link=""> <span dir="ltr"><span aria-hidden="true"><!---->Mi Name<!----></span><span class="visually-hidden"><!---->See something<!----></span></span> </a> <span class="entity-result__badge t-14 t-normal t-black--light"> <div class="display-flex flex-row-reverse align-items-baseline"> <!----> <span class="image-text-lockup__text entity-result__badge-text"> <span aria-hidden="true"><!---->• 2º<!----></span><span class="visually-hidden"><!---->example<!----></span> </span> </div> </span> </span>I wrote the following code but it does nothing.
links = driver.find_elements(By.XPATH, "//span[@class='entity-result__title-text']/a[@class='app-aware-link']") for link in links: href = link.get_attribute("href") link.click() # My Action done and I'm ready to close the website driver.back()But nothing happened.
To create a list of required elements, you must be visibility_of_all_elements_ located(), you can use any of the following locator strategies:
Use CSS_SELECTOR:
USEXPATH: