因此,我正面臨與下面的HTML交互問題。我無法打開彈出窗口並使用不同的Selenium Webdriver命令將其關閉。雖然我在這裏尋找一個特定的解決方案,但是我們也會讚賞任何有關處理Angular JS的一般技巧。我認爲問題的根本原因是我不知道使用Selenium Webdriver自動化Angular的好方法。我使用C#,但是我會從任何編程語言中獲取任何有用的信息,因爲我總是可以改進解決方案。如何使用Selenium Webdriver自動測試Angular JS
我想這個彈出按鈕,不成功互動: UIB-酥料餅的模板= 「 '/程序/學生/評估/指令/模板/ shortTextPopupTemplate.html'」
<div class="line ttsBorder">「<span style="font-style:italic;">And be it further enacted</span><span style="display: inline;">, That in all that territory ceded</span><span short-text-popup="" accession-number="VH209006" class="ng-isolate-scope" ng-non-bindable=""><a uib-popover-template="'/app/student/assessment/directives/templates/shortTextPopupTemplate.html'" popover-is-open="ctrl.isVisible" popover-trigger="none" popover-placement="auto top" tabindex="0" title="Shows more information." ng-click="buttonOnClick($event)" ng-keydown="buttonOnKeydown($event)" ng-class="['stpu-button', {disabled: ctrl.isDisabled, active: ctrl.isVisible}]" class="ng-scope stpu-button" style="z-index: 3;"></a></span> by France to the United States . . . which lies north of thirty‑six degrees and thirty minutes north latitude . . . slavery . . . shall be, and is hereby, forever prohibited.」</div>
這是我曾嘗試:
//attempt 1
var elements = Driver.FindElements(By.XPath("//*[@class='line ttsBorder']"));
//attempt 2 - UserInteractions = new Actions(Driver);
UserInteractions.MoveToElement(PopUpButton).Click().Perform();
//attempt 3
Driver.FindElement(By.XPath("//[@title='Shows more information.']")).Click();
//attempt 4
//Driver.FindElement(By.XPath("//a[@uib-popover-template]"));
PopUpButton.Click();
//attempt 5
//Working, but seems dirty - JavaExecutor.ExecuteScript("arguments[0].click();", PopUpButton);
我不得不產生tab鍵通過UI找到我想要的元素。我真的不滿意這樣一個脆弱的解決方案,並希望你能提供一些建議。
在此先感謝!