submit element not clickable selenium python - python

I was trying to open stackoverflow and search for a query and then click the search button.
almost everything went fine except I was not able to click submit button
I encountered error
WebDriverException: unknown error: Element ... is not clickable at point (608, 31). Other element would
receive the click: (Session info:
chrome=60.0.3112.101) (Driver info: chromedriver=2.29.461591
(62ebf098771772160f391d75e589dc567915b233),platform=Windows NT
6.1.7601 SP1 x86)
browser=webdriver.Chrome()
browser.get("https://stackoverflow.com/questions/19035186/how-to-select-element-with-selenium-python-xpath")
z=browser.find_element_by_css_selector(".f-input.js-search-field")#use .for class and replace space with .
z.send_keys("geckodriver not working")
submi=browser.find_element_by_css_selector(".svg-icon.iconSearch")
submi.click()

<button type="submit" class="btn js-search-submit">
<svg role="icon" class="svg-icon iconSearch" width="18" height="18" viewBox="0 0 18 18">
<path d="..."></path>
</svg>
</button>
You are trying to click on the svg. That icon is not clickable, but the button is.
So change the button selector to .btn.js-search-submit will work.

Use below code to click on submit button:
browser.find_element_by_css_selector(".btn.js-search-submit").click()

Click the element with right locator, your button locator is wrong. Other code is looking good
try this
browser=webdriver.Chrome()
browser.get("https://stackoverflow.com/questions/19035186/how-to-select-element-with-selenium-python-xpath")
z=browser.find_element_by_css_selector(".f-input.js-search-field")#use .for class and replace space with .
z.send_keys("geckodriver not working")
submi=browser.find_element_by_css_selector(".btn.js-search-submit")
submi.click()

Related

Is it possible to click button class in Selenium Python?

when I use browser.find_element_by_css_selector(".LkLjZd ScJHi OzU4dc ").click(),
Message: no such element: Unable to locate element: {"method":"css selector","selector":".LkLjZd ScJHi OzU4dc "}
This error occurs despite of element is that <button class="LkLjZd ScJHi OzU4dc " jsaction="click:TiglPc" jsname="gxjVle" style="font-family: Roboto, "Noto Sans KR", sans-serif;">total review</button>
how to click the butten....
browser.find_element_by_xpath("//button[.='total review']").click()
You can click on it by it's text value most of it's identifiers seems dynamic
you can use the xpath of the element.
Install xpath Helper in your chrome.
Refresh the page or close it and enter again.
Click on addon from the toolbar.
Shift + click the element you needed.
Than browser.find_element_by_xpath()
PS: If it's a long string you can cut the start of it and replace with another /.

can't click button with selenium python

i can't find way to press button with selenium. tried to click on it by name and xpath, but it didnt worked.
this is sign in button on this site - https://account.envato.com/sign_in?to=audiojungle
this is code of button:
<input type="submit" name="commit" value="Sign in to your account" class="js-sign-in__submit e-btn--3d -color-primary -size-m -width-full h-mb2 h-mt1">
if i try to find it by x path, using - driver.find_element_by_xpath('//*[#id="sign-in-form"]/div[6]/input').click()
or using - driver.find_element_by_name('commit').click()
it comes with this problem -
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <input type="submit" name="commit" value="Sign In"formnovalidate="formnovalidate" data-disable-with="Sign In"> is not clickable at point (789, 309). Other element would receive the click: <p style="">...</p>
i don't remember evrything i tried, but i hope you understood me. i didn't find solution in internet, so i hope you will help me, thx)
Try this:
Option 1:
wait.until(ec.visibility_of_element_located((By.XPATH,"Your xpath")
Option 2:
Check if it is not in iframe.
Option 3:
Use Action or Javascript to click on button.
Hope this helps.

Clicking the hidden input Selenium in Python

I am trying to automate the login procedure with Selenium in Firefox with Python.
That's how a login button looks like in HTML:
<td>
<input name="cmd" value="lg" type="hidden">
<input src="ok.png" style="border-style: none;" type="image">
</td>
I have tried a following method:
loginButton = driver.find_elements_by_xpath("//input[#name='cmd' and #value='lg']")[0]
loginButton.click()
It returns the following exception with an empty message.
"selenium.common.exceptions.ElementNotInteractableException: Message: "
This method returns
"Message: Element is not visible"
loginButton = driver.find_element_by_name("cmd")
loginButton.send_keys(Keys.RETURN)
Could you please explain what I am missing?
If you want to click on input next to hidden, try
loginButton = driver.find_element_by_xpath("//input[#src='ok.png']")
# loginButton = driver.find_element_by_xpath("//input[#name='cmd' and #value='lg']/following-sibling::input")
loginButton.click()

Clicking Links that arent on screen with Selenium

I'm trying to click links on a website, there's a full page of them. I tried using the is_displayed() option, I came back "true" but then still gave me this error. I've encountered this error before on other projects, its because selenium doesn't see the link. I tried putting a scroll down option in the code but that only works so many times as the page down ends up scrolling too far.
What other options do I have to get the link visible to click on?
Code:
href1 = driver.find_element_by_xpath("//*[#id='divDesktopResults']//div//div//div//a[#href='" + link + "']")
if (href1.is_displayed()):
print('true')
href1.click()
else:
print('False')
Error:
selenium.common.exceptions.WebDriverException: Message: unknown error: Element <a class="popimg" data-toggle="popover" style="text-decoration:underline;margin-right:20px;" data-content="<img style='max-width:250px;' src='/Home/GetPng?ID=D218098469' ></a>" data-html="true" data-trigger="hover" href="#pdfviewer?ID=D218098469">...</a> is not clickable at point (441, 514). Other element would receive the click: <div class="row">...</div>
(Session info: chrome=66.0.3359.181)
(Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 10.0.16299 x86_64)
Edit:
Solved another way, put all the links in an array and used driver.get instead of clicking the link.
Selenium is complaining not that the link can't be seen, but that something else is essentially on top of the link. Clicking on the screen where the link is would instead click on the "row" div. This would imply a CSS error where you have multiple elements one on top of the other. You could potentially confirm this by giving the link a really high Z value so that it sits on top of everything else and re-run your test.

Clicking on an image in selenium

I'm having an issue clicking on an image using the Chromedriver with Selenium for the following HTML:
<div class="modal_buttons">
<input type="image" name="GoButton" id="GoButton" tabindex=14 title="Continue" alt="Continue" onfocus="SetLastFocus(this.id)" src="https://t4.ftcdn.net/jpg/00/81/83/05/240_F_81830511_aJbF2vH9yufF0UAUFQ83JDnbp0jE5mNV.jpg"
I tried using the following code:
element = driver.find_element_by_css_selector("//div[img/#src='https://t4.ftcdn.net/jpg/00/81/83/05/240_F_81830511_aJbF2vH9yufF0UAUFQ83JDnbp0jE5mNV.jpg']").click()
Selenium is failing everytime, and giving the same list of errors that it can't locate the button. Any ideas how to fix?
Thanks
Try:
driver.find_element_by_xpath("//input[#id='GoButton'][#name='GoButton']").click()
or
driver.find_element_by_xpath("//input[#id='GoButton'][#title='Continue']").click()
or
driver.find_element_by_xpath("//input[#name='GoButton'][#title='Continue']").click()
or
driver.find_element_by_xpath("//input[contains(#src,'240_F_81830511_aJbF2vH9yufF0UAUFQ83JDnbp0jE5mNV.jpg')]")

Categories