0

I am able to click submit button and submit button click is working fine but text entered to add comments is not showing (basically submit button click is working ,but submit button functionality is not triggering ):

DOM:

<div _ngcontent-sfd-c33="" class="d-flex marg-top-2 ng-star-inserted">
    <button _ngcontent-sfd-c33="" class="marg-start-auto btn btn-secondary" type="button"> Cancel </button>
    <button
_ngcontent-sfd-c33="" class="btn marg-start-1 btn-primary" type="button">
        <span _ngcontent-sfd-c33=""></span>
        <adapt-busy-backdrop class="ng-tns-c8-21 ng-star-inserted"></adapt-busy-backdrop>
        <adapt-busy class="ng-star-inserted">
            <ng-component class="ng-tns-c10-23 ng-star-inserted"></ng-component>
        </adapt-busy>
        <span _ngcontent-sfd-c33="" class="ng-star-inserted">Submit</span>
    </button>
</div>

Here is my code :

WebElement submit = driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalizespace(.)='Cancel'[1]/following::span[2]"));
String submitButton = "arguments[0].style.height='auto';arguments[0].style.visibility='visible';";
((JavascriptExecutor) driver).executeScript(submitButton, submit);   
submit.click(); 

enter image description here

3
  • Instead of just the image of the web elements you are dealing with, can you also add the html code for the comments textarea / submit button?
    – Lee Jensen
    Dec 31 '19 at 15:55
  • <div _ngcontent-sfd-c33="" class="d-flex marg-top-2 ng-star-inserted"> <button _ngcontent-sfd-c33="" class="marg-start-auto btn btn-secondary" type="button"> Cancel </button> <button _ngcontent-sfd-c33="" class="btn marg-start-1 btn-primary" type="button"> <span _ngcontent-sfd-c33=""></span><adapt-busy-backdrop class="ng-tns-c8-21 ng-star-inserted"> </adapt-busy-backdrop><adapt-busy class="ng-star-inserted"> <ng-component class="ng-tns-c10-23 ng-star-inserted"> </ng-component></adapt-busy> <span _ngcontent-sfd-c33="" class="ng-star-inserted">Submit</span></button> </div> Jan 2 '20 at 7:41
  • why are you clicking the span tag? you should be clicking the button tag
    – PDHide
    Jan 2 '20 at 11:29
1

You should be clicking the Button tag and not the span tag, please use the below locator:

WebElement submit = driver.findElement(By.xpath("//span[contains(text(),'Submit')]/..")
15
  • I tried clicking button tag still i am facing same issue Jan 2 '20 at 12:41
  • Why you have the javascript executor?, use expected condition if you are looking for visibility.
    – PDHide
    Jan 2 '20 at 12:46
  • Code is throwing Element Not Visible Exception so i am using javascript to make element visible Jan 2 '20 at 12:49
  • 1
    @PremnathReddyvari you are manipulating the DOM!!! so if the test fails still you are forcefully passing it . Imagine the bug is that submit button never becomes visible adn you are doing it through script which is a 'False Negative'
    – PDHide
    Jan 2 '20 at 12:57
  • 1
    Thanks for the help hide, code is working fine when i use chrome driver but when i try using html driver i am facing all these issues Jan 2 '20 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.