我正在自动化一个网络界面。有些框架是基于 Angular JS 的。 我正在尝试访问动态列内的 ng-repeat。
这是我的 DOM 的片段:
<div class="containCol__col column-animation col0" ng-repeat="column
in sbCtrl.SlideboardStore.columns track by`
sbCtrl.getUniqueColumnId(column)" column-id="emptydata" ng-class="
{'enabled': column.showNewCardInput, 'containCol__col__collapsed':
column.isCollapsed}" style="opacity: 1;">
所以在这里你可以看到 ng-repeat 是动态的并且取决于列 ID:
ng-repeat="column in sbCtrl.SlideboardStore.columns track
bysbCtrl.getUniqueColumnId(column)
这是我在 Selenium 中尝试做的事情:
WebDriverFactory.getDriver().findElement(ByAngular.withRootSelector("#application-container").exactRepeater());
现在我的问题是如何找到中继器的选择器,因为它是动态的,我想先选择列,但因为它不是框架,我不知道如何处理这个问题。
提前致谢
最佳答案
大家好,刚刚找到了答案,我已经从选择器中删除了动态部分,并通过 Xpath 选择了列,它的工作方式就像一个魅力。
WebElement repeater = WebDriverFactory.getDriver().findElement(ByAngular.withRootSelector("#application-container").exactRepeater("column in sbCtrl.SlideboardStore.columns"));
关于javascript - 使用 selenium 和 ngWebDriver 访问动态 ng-repeat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49500177/