Is there a selenium function to click on area element with a particular class
I am working on Selenium with Python. I am quite new to this and I am trying to click on an image which has the following HTML
structure:
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>
I have tried a couple of things, for example:
driver.find_element_by_xpath('//img/@class="img-450"').click()
driver.find_element_by_xpath('//area[@class="cursor"]').click()
but, I seem to always end up with errors, for example:
selenium.common.exceptions.WebDriverException: Message: unknown error: shape= is not supported
or
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.
I am wondering if I can somehow click on the image using the area element.
Any thoughts which can point me in the right direction would be great. Thanks.
selenium selenium-chromedriver
add a comment |
I am working on Selenium with Python. I am quite new to this and I am trying to click on an image which has the following HTML
structure:
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>
I have tried a couple of things, for example:
driver.find_element_by_xpath('//img/@class="img-450"').click()
driver.find_element_by_xpath('//area[@class="cursor"]').click()
but, I seem to always end up with errors, for example:
selenium.common.exceptions.WebDriverException: Message: unknown error: shape= is not supported
or
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.
I am wondering if I can somehow click on the image using the area element.
Any thoughts which can point me in the right direction would be great. Thanks.
selenium selenium-chromedriver
1
Please share relevant HTML clock
– Ishita Shah
Dec 31 '18 at 7:45
Added the html code
– kashf34Kashf
Dec 31 '18 at 8:06
see this stackoverflow.com/questions/44812012/…
– murali selenium
Dec 31 '18 at 8:21
add a comment |
I am working on Selenium with Python. I am quite new to this and I am trying to click on an image which has the following HTML
structure:
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>
I have tried a couple of things, for example:
driver.find_element_by_xpath('//img/@class="img-450"').click()
driver.find_element_by_xpath('//area[@class="cursor"]').click()
but, I seem to always end up with errors, for example:
selenium.common.exceptions.WebDriverException: Message: unknown error: shape= is not supported
or
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.
I am wondering if I can somehow click on the image using the area element.
Any thoughts which can point me in the right direction would be great. Thanks.
selenium selenium-chromedriver
I am working on Selenium with Python. I am quite new to this and I am trying to click on an image which has the following HTML
structure:
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>
I have tried a couple of things, for example:
driver.find_element_by_xpath('//img/@class="img-450"').click()
driver.find_element_by_xpath('//area[@class="cursor"]').click()
but, I seem to always end up with errors, for example:
selenium.common.exceptions.WebDriverException: Message: unknown error: shape= is not supported
or
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.
I am wondering if I can somehow click on the image using the area element.
Any thoughts which can point me in the right direction would be great. Thanks.
<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>
<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>
selenium selenium-chromedriver
selenium selenium-chromedriver
edited Jan 1 at 7:07
kashf34Kashf
asked Dec 31 '18 at 7:13
kashf34Kashfkashf34Kashf
336
336
1
Please share relevant HTML clock
– Ishita Shah
Dec 31 '18 at 7:45
Added the html code
– kashf34Kashf
Dec 31 '18 at 8:06
see this stackoverflow.com/questions/44812012/…
– murali selenium
Dec 31 '18 at 8:21
add a comment |
1
Please share relevant HTML clock
– Ishita Shah
Dec 31 '18 at 7:45
Added the html code
– kashf34Kashf
Dec 31 '18 at 8:06
see this stackoverflow.com/questions/44812012/…
– murali selenium
Dec 31 '18 at 8:21
1
1
Please share relevant HTML clock
– Ishita Shah
Dec 31 '18 at 7:45
Please share relevant HTML clock
– Ishita Shah
Dec 31 '18 at 7:45
Added the html code
– kashf34Kashf
Dec 31 '18 at 8:06
Added the html code
– kashf34Kashf
Dec 31 '18 at 8:06
see this stackoverflow.com/questions/44812012/…
– murali selenium
Dec 31 '18 at 8:21
see this stackoverflow.com/questions/44812012/…
– murali selenium
Dec 31 '18 at 8:21
add a comment |
1 Answer
1
active
oldest
votes
Based on the HTML you've shared, You could try this code :
wait = WebDriverWait(driver, 10)
img= wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'div#result>img')))
img.click()
Make sure to import these :
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
I tried this but encountered the following error: Element <img class="img-450" usemap="#677005183" src="#" border="0" title="Click on a repeated (mirrored) image bellow" alt=""> is not clickable at point (468, 332). Other element would receive the click: <area class="cursor" onclick="javascript:Captcha107('d1b40ts8');" title="Click on a repeated (mirrored) image bellow" coords="192,4,255,88">
– kashf34Kashf
Jan 1 at 7:02
What is the view point of element ?
– cruisepandey
Jan 1 at 7:55
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53984643%2fis-there-a-selenium-function-to-click-on-area-element-with-a-particular-class%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Based on the HTML you've shared, You could try this code :
wait = WebDriverWait(driver, 10)
img= wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'div#result>img')))
img.click()
Make sure to import these :
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
I tried this but encountered the following error: Element <img class="img-450" usemap="#677005183" src="#" border="0" title="Click on a repeated (mirrored) image bellow" alt=""> is not clickable at point (468, 332). Other element would receive the click: <area class="cursor" onclick="javascript:Captcha107('d1b40ts8');" title="Click on a repeated (mirrored) image bellow" coords="192,4,255,88">
– kashf34Kashf
Jan 1 at 7:02
What is the view point of element ?
– cruisepandey
Jan 1 at 7:55
add a comment |
Based on the HTML you've shared, You could try this code :
wait = WebDriverWait(driver, 10)
img= wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'div#result>img')))
img.click()
Make sure to import these :
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
I tried this but encountered the following error: Element <img class="img-450" usemap="#677005183" src="#" border="0" title="Click on a repeated (mirrored) image bellow" alt=""> is not clickable at point (468, 332). Other element would receive the click: <area class="cursor" onclick="javascript:Captcha107('d1b40ts8');" title="Click on a repeated (mirrored) image bellow" coords="192,4,255,88">
– kashf34Kashf
Jan 1 at 7:02
What is the view point of element ?
– cruisepandey
Jan 1 at 7:55
add a comment |
Based on the HTML you've shared, You could try this code :
wait = WebDriverWait(driver, 10)
img= wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'div#result>img')))
img.click()
Make sure to import these :
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
Based on the HTML you've shared, You could try this code :
wait = WebDriverWait(driver, 10)
img= wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'div#result>img')))
img.click()
Make sure to import these :
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
answered Dec 31 '18 at 8:59


cruisepandeycruisepandey
4,2762619
4,2762619
I tried this but encountered the following error: Element <img class="img-450" usemap="#677005183" src="#" border="0" title="Click on a repeated (mirrored) image bellow" alt=""> is not clickable at point (468, 332). Other element would receive the click: <area class="cursor" onclick="javascript:Captcha107('d1b40ts8');" title="Click on a repeated (mirrored) image bellow" coords="192,4,255,88">
– kashf34Kashf
Jan 1 at 7:02
What is the view point of element ?
– cruisepandey
Jan 1 at 7:55
add a comment |
I tried this but encountered the following error: Element <img class="img-450" usemap="#677005183" src="#" border="0" title="Click on a repeated (mirrored) image bellow" alt=""> is not clickable at point (468, 332). Other element would receive the click: <area class="cursor" onclick="javascript:Captcha107('d1b40ts8');" title="Click on a repeated (mirrored) image bellow" coords="192,4,255,88">
– kashf34Kashf
Jan 1 at 7:02
What is the view point of element ?
– cruisepandey
Jan 1 at 7:55
I tried this but encountered the following error: Element <img class="img-450" usemap="#677005183" src="#" border="0" title="Click on a repeated (mirrored) image bellow" alt=""> is not clickable at point (468, 332). Other element would receive the click: <area class="cursor" onclick="javascript:Captcha107('d1b40ts8');" title="Click on a repeated (mirrored) image bellow" coords="192,4,255,88">
– kashf34Kashf
Jan 1 at 7:02
I tried this but encountered the following error: Element <img class="img-450" usemap="#677005183" src="#" border="0" title="Click on a repeated (mirrored) image bellow" alt=""> is not clickable at point (468, 332). Other element would receive the click: <area class="cursor" onclick="javascript:Captcha107('d1b40ts8');" title="Click on a repeated (mirrored) image bellow" coords="192,4,255,88">
– kashf34Kashf
Jan 1 at 7:02
What is the view point of element ?
– cruisepandey
Jan 1 at 7:55
What is the view point of element ?
– cruisepandey
Jan 1 at 7:55
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53984643%2fis-there-a-selenium-function-to-click-on-area-element-with-a-particular-class%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Please share relevant HTML clock
– Ishita Shah
Dec 31 '18 at 7:45
Added the html code
– kashf34Kashf
Dec 31 '18 at 8:06
see this stackoverflow.com/questions/44812012/…
– murali selenium
Dec 31 '18 at 8:21