2017-03-13 19 views
1

在我的Angular應用程序中,我正在用它的id標識一個元素。但是它在執行過程中不承認以下是我的細節。元素無法正確識別,最新錯誤?

在我的屏幕上,我有一個貸款數量控制與貸款值和複選框作爲選中狀態。我必須瞭解在屏幕啓動後是否檢查此貸款編號。我用它的標識(id)編寫了腳本,但在執行期間它不能識別,並且拋出「元素不可見」錯誤。任何幫助,請..

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> 

,當我和我的開發人員檢查,他說,他已經把「ID」這個複選框控制爲「loanNumberid」我也照本宣科這一點。但是當我檢查它實際上顯示<lable>控制,我對此感到困惑。這裏是我的硒代碼

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

chkloan.click(); 

,我也得到了錯誤的...

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) 
+0

xpath測試 –

+0

謝謝。但我不確定它爲什麼指向標籤控件,雖然它有指定了id的角度輸入字段。 – mmar

+0

我不確定它,但沒有輸入複選框的結束標記,所以我認爲你需要像這樣封閉標籤'' –

回答

-1
  1. 確保有與相同的ID沒有元素在DOM模型
  2. 確保元素與smthn不重疊
  3. 請嘗試單擊JS,使用Actions
+0

如果它重疊,它會給出一個不同的錯誤...另一個元素會收到點擊。使用JSE不是用戶場景,因爲沒有用戶會使用JSE來使元素可見或點擊它。操作也不會點擊不可見的元素。 – JeffC

+0

@Mikhail - 出於某種原因,我期望的複選框元素在腳本執行期間在頁面中不可見,並且腳本始終表示錯誤消息'元素不可見...'。但是我使用了這個js'((JavascriptExecutor)驅動程序).executeScript(「arguments [0] .click();」,chkloan);'執行程序和它的工作完美,checbox被點擊和dono如何。無論如何感謝提示。 – mmar