Cannot click Submit Button

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Cannot click Submit Button

Small World
There are five Dialog boxes and each Dialog box has the same code for the Submit Button except the value changes for "id" and "onclick".
A single Dialog box has five question and when one answer for each question is selected the Submit button gets enabled.

Code before button gets Enabled
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<div class="modal-footer">
                                    <input type="button" id="3118" class="btn btn-danger RejectionModal" value="Decline">
                                    <input type="button" id="btnSubmit_3118" disabled="disabled" style="opacity: 0.5;" onclick="submitObservation(3118,653);" class="btn btn-primary review-submission" value="Submit">

                                </div>
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Code after button gets Enabled
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<div class="modal-footer">
                                    <input type="button" id="3118" class="btn btn-danger RejectionModal" value="Decline">
                                    <input type="button" id="btnSubmit_3118" style="opacity: 1;" onclick="submitObservation(3118,653);" class="btn btn-primary review-submission" value="Submit">

                                </div>
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


The code which I used to click the Submit button 

JavascriptExecutor executor1 = (JavascriptExecutor)driver;

 WebElement element1 = driver.findElement(By.xpath("//*[contains(@class,'btn btn-primary review-submission') and contains(@style,'opacity: 1;')]"));
  
 executor1.executeScript("arguments[0].click();", element1); 


The above code works fine for the First Submit button but not for the rest.

The exception that throws is :               
org.openqa.selenium.NoSuchElementException: Unable to locate element: //*[contains(@class,'btn btn-primary review-submission') and contains(@style,'opacity: 1;')]

Thanks & Regards,
Small World

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/e09b2a62-b5f7-4e7f-9909-5a69fc011c73o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Cannot click Submit Button

naveen-41
 and contains(@style,'opacity: 1;')]") remove this line and excute only with xpath.
Also, give some delay time after loading the URL for loading the full page.

On Tue, Jun 30, 2020 at 11:04 AM Small World <[hidden email]> wrote:
There are five Dialog boxes and each Dialog box has the same code for the Submit Button except the value changes for "id" and "onclick".
A single Dialog box has five question and when one answer for each question is selected the Submit button gets enabled.

Code before button gets Enabled
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<div class="modal-footer">
                                    <input type="button" id="3118" class="btn btn-danger RejectionModal" value="Decline">
                                    <input type="button" id="btnSubmit_3118" disabled="disabled" style="opacity: 0.5;" onclick="submitObservation(3118,653);" class="btn btn-primary review-submission" value="Submit">

                                </div>
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Code after button gets Enabled
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<div class="modal-footer">
                                    <input type="button" id="3118" class="btn btn-danger RejectionModal" value="Decline">
                                    <input type="button" id="btnSubmit_3118" style="opacity: 1;" onclick="submitObservation(3118,653);" class="btn btn-primary review-submission" value="Submit">

                                </div>
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


The code which I used to click the Submit button 

JavascriptExecutor executor1 = (JavascriptExecutor)driver;

 WebElement element1 = driver.findElement(By.xpath("//*[contains(@class,'btn btn-primary review-submission') and contains(@style,'opacity: 1;')]"));
  
 executor1.executeScript("arguments[0].click();", element1); 


The above code works fine for the First Submit button but not for the rest.

The exception that throws is :               
org.openqa.selenium.NoSuchElementException: Unable to locate element: //*[contains(@class,'btn btn-primary review-submission') and contains(@style,'opacity: 1;')]

Thanks & Regards,
Small World

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/e09b2a62-b5f7-4e7f-9909-5a69fc011c73o%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CACrE7jRyOushR9CcC16MZHtMnW05xSF0rGmsdBzPEaS%2B2X8Bpg%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Cannot click Submit Button

Adrian-2
In reply to this post by Small World
HI,
Try driver.findElement(By.cssSelector("input[id^='btnSubmit']"))
This will find the button with the id that starts with btnSubmit

Regards,
Adrian.


On Tuesday, 30 June 2020 15:33:35 UTC+10, Small World wrote:
There are five Dialog boxes and each Dialog box has the same code for the Submit Button except the value changes for "id" and "onclick".
A single Dialog box has five question and when one answer for each question is selected the Submit button gets enabled.

Code before button gets Enabled
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<div class="modal-footer">
                                    <input type="button" id="3118" class="btn btn-danger RejectionModal" value="Decline">
                                    <input type="button" id="btnSubmit_3118" disabled="disabled" style="opacity: 0.5;" onclick="submitObservation(3118,653);" class="btn btn-primary review-submission" value="Submit">

                                </div>
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Code after button gets Enabled
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<div class="modal-footer">
                                    <input type="button" id="3118" class="btn btn-danger RejectionModal" value="Decline">
                                    <input type="button" id="btnSubmit_3118" style="opacity: 1;" onclick="submitObservation(3118,653);" class="btn btn-primary review-submission" value="Submit">

                                </div>
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


The code which I used to click the Submit button 

JavascriptExecutor executor1 = (JavascriptExecutor)driver;

 WebElement element1 = driver.findElement(By.xpath("//*[contains(@class,'btn btn-primary review-submission') and contains(@style,'opacity: 1;')]"));
  
 executor1.executeScript("arguments[0].click();", element1); 


The above code works fine for the First Submit button but not for the rest.

The exception that throws is :               
org.openqa.selenium.NoSuchElementException: Unable to locate element: //*[contains(@class,'btn btn-primary review-submission') and contains(@style,'opacity: 1;')]

Thanks & Regards,
Small World

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/46e94d50-951f-4ff9-8325-476c1100bd00o%40googlegroups.com.