0

The submit button does not get clicked when tried in the window which is opened by Chrome driver (Even tried hitting the button manually in the Chrome controlled window) in the Automated run(Using pytest selenium-python).

However there is no issue with the button in the application as I am able to click the same button manually in the application.

Below is the HTML for the submit button:

 <a title="Submit" rel="tool" data-placement="bottom" data-bind="click: showSubmitPopup, css: {'btn': true, 'disabled': workflow.isDirty()}, visible: work.id() != null" class="btn" style="">
          <i class="ka ja-jw ka-play"></i>
        </a>

I tried the below methods which didn't work:

1.) driver.find_element(By.CSS_SELECTOR, "[title='Submit'] > .a").click()
2.) driver.execute_script('arguments[0].scrollIntoView();', element)
3.) ActionChains(driver).move_to_element_with_offset(element, 0, 0).perform()
4.) driver.get_action_driver().move_to_element(element).click().perform()
5.) Updated the chrome & chrome driver to latest version

Any pointers appreciated !!

10
  • What error are you getting here? BTW 2,3,5 are not performing click... Commented May 26, 2021 at 11:19
  • @Prophet I get an error Error Finding Element for the next element after the submit button .... so issue here is selenium is able to click on the above submit button but click is not successful although its been clicked, so the error is thrown for the subsequent next element as Selenium already clicked the current Submit button Commented May 26, 2021 at 12:00
  • I had tried 2,3 & 5 assuming element was not clickable but later realised that the element click is being done by selenium but its not successful. Commented May 26, 2021 at 12:02
  • html you shared for the button is the same across all browsers? Commented May 26, 2021 at 12:06
  • yes @itronic1990 Commented May 26, 2021 at 12:10

2 Answers 2

1

Can you give a try using the below way

# Find Element using Xpath
element = driver.find_element_by_xpath("//a[@class='btn' and @title='Submit']")

# Click on the button using Javascript Executor
driver.execute_script("arguments[0].click();", element)
Sign up to request clarification or add additional context in comments.

3 Comments

This does not work either, same issue in which element is clicked but not successful
Okay, I think you may want to look at this question - stackoverflow.com/questions/57046606/…. The answer given mentions of capturing X-Y co-ord and performing mouse actions. I guess that is the only way here. If not, verify for frames present for this button ( This most likely is the case )
There are no IFrames in the app, Just for FYI driver.find_element(By.CSS_SELECTOR, "[title='Submit'] > .a").click() this used to work without issues. I doubt screen coordinate workaround will also work either as the click operation is happening but isn't successful, but will try.
0

This seems to be a bug with Selenium as the click operation fails.

The workaround here is to refresh the webpage just before selenium attempts to click on the button.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.