簡體   English   中英

如何在帶有C#的Selenium中使用特定DIV上的滾動來單擊按鈕

[英]How to click button using scroll on a specific DIV using Selenium with C#

我需要單擊彈出窗口底部的“保存”按鈕。 首先,我編寫了代碼以僅單擊“保存”按鈕,但出現異常“按鈕在點(869,383)不可單擊”。 好的,我想,我將滾動到彈出窗口的底部,以便該按鈕可見並且可以單擊。 我實現了向下滾動到按鈕可見位置的代碼,但是仍然出現“按鈕不可點擊”的異常,並且該按鈕未被單擊。 請幫忙

這是我的代碼

//To scroll down to the bottom of pop up window
IJavaScriptExecutor down = (IJavaScriptExecutor)driver;
down.ExecuteScript("arguments[0].scrollTop = arguments[1];", driver.FindElement(By.Id("move_In")), 1000);
 //Click Save button       
driver.FindElement(By.XPath("//button[contains(.,'Save')]")).Click();

這是網頁中的元素:

圖片

這是您如何在Java中使用javascript單擊按鈕,我確信它在C#中非常相似

WebElement button = driver.findElement(By.id("someid"));
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("arguments[0].click();", button);

暫無
暫無

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

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