Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

selenium scroll to element

element = driver.find_element(By.XPATH, "Whatever xpath you want")
driver.execute_script("return arguments[0].scrollIntoView();", element)
Comment

selenium scroll to element c#

var element = driver.FindElement(By.id("element-id"));
Actions actions = new Actions(driver);
actions.MoveToElement(element);
actions.Perform();
Comment

selenium scroll to element c#

public void ScrollTo(int xPosition = 0, int yPosition = 0)
{
    var js = String.Format("window.scrollTo({0}, {1})", xPosition, yPosition);
    JavaScriptExecutor.ExecuteScript(js);
}

public IWebElement ScrollToView(By selector)
{
    var element = WebDriver.FindElement(selector);
    ScrollToView(element);
    return element;
}

public void ScrollToView(IWebElement element)
{
    if (element.Location.Y > 200)
    {
        ScrollTo(0, element.Location.Y - 100); // Make sure element is in the view but below the top navigation pane
    }

}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# yield keyword 
Csharp :: group by unique c# 
Csharp :: how to set the value of a textbox textmode=date asp.net c# 
Csharp :: linked list revrse 
Csharp :: Search for a value into a list in c# 
Csharp :: variable size in memory c# 
Csharp :: c# ternary operator 
Csharp :: c# check if array contains value 
Csharp :: #ifdef in c 
Csharp :: linq find object from id 
Csharp :: c# show list in richtextbox 
Csharp :: tostring format 2 decimals 
Csharp :: C# unit test exception using attribrute 
Csharp :: unity set parent canvas 
Csharp :: ignore ssl c# 
Csharp :: mysqldump - date 
Csharp :: unity singleton 
Csharp :: animation setbool unity 
Csharp :: viewBag as a list 
Csharp :: async await c# 
Csharp :: label wpf 
Csharp :: c# const 
Csharp :: loading player preferences unity 
Csharp :: how to check type in c# 
Csharp :: c# list any retun indec 
Csharp :: c# json 
Csharp :: redis cache repository .net 
Csharp :: asp net c# browser cursor wait 
Csharp :: get first number in string C# 
Csharp :: Unlit shader get the direction of camera UNity 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =