簡體   English   中英

使用Watin單擊下拉菜單按鈕

[英]Click a Dropdown Menu Button using Watin

我正在使用Watin在頁面中測試網站,這里有下拉菜單按鈕,例如 <代碼> \\ [下載| V \\] </代碼> 如果我找到該按鈕並單擊,則單擊整個按鈕並選擇菜單中的第一個選項,但是我想單擊按鈕的V以顯示dropdown菜單( div ),然后從中選擇該選項,即我曾嘗試過的代碼點擊按鈕

ff.Button(Find.By("aria-describedby", "x-auto-456")).FireEvent("onmouseover");
ff.Button(Find.By("aria-describedby", "x-auto-456")).FireEvent(" Onmousedown");
ff.Button(Find.By("aria-describedby", "x-auto-456")).Click();

按鈕HTML

<button class="x-btn-text" style="position: relative; width: 16px;" type="button" tabindex="0" aria-describedby="x-auto-456">

編輯:

我曾嘗試在按鈕中找到Image的坐標,然后使用以下代碼單擊它,但是它一點都不起作用,這一點使我如何單擊按鈕並顯示div而不是自動選擇一個選項,

NameValueCollection eventProps = new NameValueCollection();
eventProps.Add("clientY", "240");
eventProps.Add("clientX", "240");
ff.Button(Find.By("aria-describedby", "x-auto-456")).FireEvent("onClick",eventProps);

您找不到正確的按鈕:

Button button = ff.Button(Find.ByClass("x-auto-457"));

您需要按按鈕的類名找到它。 請注意,將找到具有該類名稱的第一個<button><input type="button|submit|reset">元素。 如果仍然無法獲得正確的按鈕,請檢查頁面上有多少個按鈕具有x-auto-457作為類屬性值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM