Я работаю над Selenium с Python.Я новичок в этом, и я пытаюсь нажать на изображение, которое имеет следующую структуру HTML
:
HTML:
<div id="result">
<img class="img-450" usemap="#476872907" src="#" border="0" title="Click on a repeated (mirrored) image bellow" alt="">
<map name="476872907">
<area class="cursor" onclick="javascript:Captcha107('6k9frpw1');" title="Click on a repeated (mirrored) image bellow" coords="1,4,63,88">
<area class="cursor" onclick="javascript:Captcha107('ya3ltbiv');" title="Click on a repeated (mirrored) image bellow" coords="65,4,128,88">
<area class="cursor" onclick="javascript:Captcha107('9rbukmey');" title="Click on a repeated (mirrored) image bellow" coords="129,4,191,88">
<area class="cursor" onclick="javascript:Captcha107('5mlv909r');" title="Click on a repeated (mirrored) image bellow" coords="192,4,255,88">
<area class="cursor" onclick="javascript:Captcha107('eu7idjnz');" title="Click on a repeated (mirrored) image bellow" coords="257,4,319,88">
<area class="cursor" onclick="javascript:Captcha107('al9a6zih');" title="Click on a repeated (mirrored) image bellow" coords="321,4,384,88">
<area class="cursor" onclick="javascript:Captcha107('nyvkjeoc');" title="Click on a repeated (mirrored) image bellow" coords="385,4,448,88">
</map>
</div>
Я пробовал пару вещей, например:
driver.find_element_by_xpath('//img/@class="img-450"').click()
driver.find_element_by_xpath('//area[@class="cursor"]').click()
, но, кажется, я всегда получаю ошибки, например:
selenium.common.exceptions.WebDriverException: Message: unknown error: shape= is not supported
или
sselenium.common.exceptions.InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression //img/@class="img-450" because of the following error: TypeError: Failed to execute 'evaluate' on 'Document': The result is not a node set, and therefore cannot be converted to the desired type.
Мне интересно, могу ли я как-то щелкнуть по изображению, используя элемент области.
Любые мысли, которые могут указать мне правильное направлениебыло бы замечательно.Спасибо.