I'm trying to use relative locators in selenium 4, but I'm not having much luck with it.
I found an example here, but even though I'm able to find the first element, the second line doesn't work and it seems to be stuck there (I cannot close the browser automatically afterwards).
decision_div = browser.find_element(By.CLASS_NAME, "decisions")
conclusion_div = browser.find_element(locate_with(By.TAG_NAME, "div").below(decision_div))
How can I get it to find the next div right below the one with the specified class name?
As you are able to find the first element, I don't see any issues in your code as such:
You just need to ensure that the the element with the value of class attribute as
decisionsis above the desired<div>element as follows:Note : You have to add the following imports :
References
You can find a couple of relevant detailed discussions in: