I have page look like this
when I click B button then whole row hide
I need selenium to click on B button then on next B button
but I can't figure how I try locate using xpath or class
driver.find_element_by_xpath("//*[contains(@class, 'farm_icon_b')]").click()
but it didnt work
I try to user array
arr = []
driver.find_element_by_xpath("//*[contains(@class, 'farm_icon_b')]")[0].click()
but nothing too
<a href="#" onclick="return Accountmanager.farm.sendUnits(this, 4352, 6820)" class="farm_village_4352 farm_icon farm_icon_b"></a>
I have idea to execute Accountmanager.farm.sendUnits(this, 4352, 6820)
but numbers 4352, 6820 are different every time
any idea please ?
edit
i tried
entries_count =
len(driver.find_elements_by_css_selector(".farm_icon.farm_icon_b"))
for index in range(entries_count):
current_len =
len(driver.find_elements_by_css_selector(".farm_icon.farm_icon_b"))
driver.find_elements_by_css_selector(".farm_icon.farm_icon_b")[entries_count - index - 1].click()
wait.until(lambda driver: len(driver.find_elements_by_css_selector(".farm_icon.farm_icon_b")) == current_len - 1)
but getting ths error
raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: Element is not clickable at point (833, 706). Other element would receive the click: ... (Session info: chrome=64.0.3282.186) (Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 10.0.16299 x86_64)
in div id linkCotainer is not interesting but here
<div id="linkContainer"> <a href="#" class="world_button_active evt-world-selection-toggle">Svět 57</a> <a href="https://forum.divokekmeny.cz" class="footer-link" target="_blank">Fórum</a> - <a href="https://help.divokekmeny.cz" class="footer-link" target="_blank">Nápověda</a> - <a href="/game.php?village=4549&screen=settings&mode=ticket" class="footer-link" target="_blank">Support</a> - <a href="/game.php?village=4549&screen=settings&mode=ref&source=bottom_menu" class="footer-link">Pozvat hráče</a> - <a href="/game.php?village=4549&screen=memo" class="footer-link">Poznámkový blok</a> - <a href="/game.php?village=4549&screen=&action=logout&h=278e0f2a" target="_top" class="footer-link">Odhlášení </a> </div>
It is telling you why it can't click on your element:
Other element would receive the click: <div id="linkContainer">...</div>
To troubleshoot this, first find the element that is blocking the one that you want by going to the dev tools in your browser, clicking the console tab, and looking for the element that is stealing your click:
$$("div[id='linkContainer']")
If that returns an element in the console, expand it by clicking the arrow and hover over the subelements. Do you see anything highlighting on the page? If so, that is what is getting your click, and you can formulate a new approach from there.
It is very possible that something is hiding the element you want to click. You can also save yourself a lot of time if you set a debug point in your code and try to locate the element manually at the precise point where you would locate it in your script:
import pdb; pdb.set_trace() # This will drop you into a Python prompt
driver.find_element_by_xpath("//*[contains(@class, 'farm_icon_b')]").click()
Once your script hits the debug point, it will give you the Python prompt with all of your variables intact, so you can manipulate the browser with driver until you have discovered the problem.
Happy hunting.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.