0

I have faced a critical problem in my work. I have passed 2 days but can not solve it. I have used several options but not working in automation but working in manual processes. I know I am wrong but can not find it. I also use explicit and implicit wait.

I used the following code to submit a form.

By btnSubmit = By.id("btnSubmit");

  • driver.findElement(btnSubmit).click();
  • driver.findElement(btnSubmit).submit();
  • javaScript.executeScript("arguments[0].click();", driver.findElement(btnSubmit));
public Object executeScript(String script, Object... args) {
        JavascriptExecutor js = (JavascriptExecutor) driver;
        return js.executeScript(script, args);
    }
javaScript.executeScript("document.getElementById('btnSubmit').setAttribute('class','btn-small');");

this code added class in "btnSubmit".

But click not working. If you have time would you please give me feedback. I have attached some scenarios.

enter image description here enter image description here enter image description here

Do not worry about console error, I have checked when I do manual click on submit button, it works.

7
  • Can you share link to the website
    – PDHide
    Commented Nov 19, 2020 at 16:39
  • Are you sure nothing happens? In the JS a checkbox is checked if checked (O_o), is it? Can't spot it on the screens.
    – bish
    Commented Nov 19, 2020 at 17:10
  • @PDHide sorry I can't. Commented Nov 19, 2020 at 17:22
  • @bish when submit button clicked page load, but no page loading happen. Yes something happen, because I can add css class "btn-small". Commented Nov 19, 2020 at 17:29
  • Based on your eclipse console log, it successfully clicked the "btnSubmit". I assume that it's either there's issue with your data that's why it won't proceed or that element is not really the trigger. Commented Nov 20, 2020 at 2:47

0

Your Answer

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

Browse other questions tagged or ask your own question.