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