1

in my Angular application i am identifying an element with its id. But its not recognizing during the execution and below are my details.

In my screen, i have a Loan number control with loan value and its checkbox as checked state. I have to find out whether after the screen launch, this loan number is checked or not. I have scripted with its identified (id) but during the execution it not recognized and it throws 'Element not visible' error. Any help please..

enter image description here

<section class="verification-element" data-ng-show="$ctrl.value || $ctrl.vmodel=='isIvrVerified'" aria-hidden="false">
    <div class="verification-element--nameValue" data-ng-switch="$ctrl.type">
        <label for="loanNumberid" class="verification-element__name ng-binding">LOAN NUMBER</label>

        <!-- ngSwitchWhen: address -->
        <!-- ngSwitchWhen: percentage -->
        <!-- ngSwitchWhen: select -->
        <!-- ngSwitchDefault: --><span class="verification-element__value ng-binding ng-scope" id="loanNumberValueId" data-ng-switch-default="">0553101437</span><!-- end ngSwitchWhen: -->

    </div>
    <div class="verification-element--checkbox saturn-checkbox">
        <input class="checkBoxFirstPanel ng-pristine ng-untouched ng-valid ng-empty" type="checkbox" name="loanNumber" id="loanNumberid" data-ng-checked="true" data-ng-model="$ctrl.thing" data-ng-click="$ctrl.checkedElement({name: $ctrl.vmodel, value: $ctrl.thing})" checked="checked" aria-invalid="false" style="">
        <label for="loanNumberid"></label>
    </div>
</section>

When i checked with my developer, he says that he has put 'id' for this checkbox control as "loanNumberid" i also scripted with that. but when i inspect it actually shows the <lable> control and i am confused on this. here is my selenium code

@FindBy(id = "loanNumberid") 
public static WebElement chkloan;

chkloan.click();

and i get the error as...

 org.openqa.selenium.ElementNotVisibleException: element not visible
        (Session info: chrome=56.0.2924.76)
        (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
      Command duration or timeout: 23 milliseconds
      Build info: version: '2.43.1', revision: '5163bceef1bc36d43f3dc0b83c88998168a363a0', time: '2014-09-10 09:43:55'
      System info: host: 'MUS5CG6030CWS', ip: '10.219.18.222', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_92'
      Driver info: org.openqa.selenium.chrome.ChromeDriver
      Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed), userDataDir=C:\Users\par964\AppData\Local\Temp\scoped_dir17000_14241}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=56.0.2924.76, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
      Session ID: a8514260e4e55f5ff09b60d0196223f4
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
        at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
        at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:79)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:50)
        at com.sun.proxy.$Proxy15.click(Unknown Source)
        at com.capitalone.Pages.NewVerificationModal.clickCheckBoxes(NewVerificationModal.java:360)
        at com.capitalone.Steps.Saturn_Login.selectElements(Saturn_Login.java:490)
        at ?.And I select fields on verification panel(src/test/resources/feature/SmokeCICD/NotesMemo.feature:12)
mmar
  • 1,840
  • 6
  • 28
  • 41
  • test with xpath – Akash KC Mar 13 '17 at 21:56
  • Thanks. But i am not sure why its is pointing to label control though it has angular input field with id specified. – mmar Mar 13 '17 at 22:03
  • I am not sure about it but there is no closing tag for input checkbox, so I think you need to have enclosing tag like this `` – Akash KC Mar 13 '17 at 22:06
  • You might try waiting for the element to be visible. There may be a delay before it actually becomes visible. You could also try a CSS selector, `input[name='loanNumber']`. – JeffC Mar 14 '17 at 04:20
  • Tried by css selector also. still its not recognizing..any other suggestion please..This actually blocks our testing... – mmar Mar 14 '17 at 16:52

1 Answers1

-1
  1. Make sure that there are no elements with same ID in the DOM model
  2. Make sure that element is not overlapped with smthn else
  3. Try clicking either JS, either using Actions
Community
  • 1
  • 1
Mikhail
  • 665
  • 4
  • 16
  • If it were overlapped, it would give a different error... another element would receive the click. Using JSE is not a user scenario because no user will use JSE to make the element visible or to click it. Actions won't click an invisible element either. – JeffC Mar 14 '17 at 04:22
  • @Mikhail - for some reason my expected checkbox element is not visible in the page during the script execution and script always says that error message 'element not visible...'. But i used this js `((JavascriptExecutor)driver).executeScript("arguments[0].click();", chkloan);` executor and it works perfectly and the checbox is clicked and dono how. Anyways thanks for the hint. – mmar Mar 14 '17 at 22:07