0% found this document useful (0 votes)
12 views1 page

As 1357

The document provides a code snippet for using Selenium WebDriver to navigate web pages, interact with elements, and perform actions such as clicking, sending keys, and selecting options. It includes examples of various selectors and methods for element manipulation. Additionally, it demonstrates how to use JavaScript within Selenium to interact with elements on a webpage.

Uploaded by

Anuj Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

As 1357

The document provides a code snippet for using Selenium WebDriver to navigate web pages, interact with elements, and perform actions such as clicking, sending keys, and selecting options. It includes examples of various selectors and methods for element manipulation. Additionally, it demonstrates how to use JavaScript within Selenium to interact with elements on a webpage.

Uploaded by

Anuj Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

dghdf dfgdgdgf hffdggfhjkvccbcgddgdfdfffgdgrdfgdgdfge3kj ,lfhfddggd gdfgd2 dhdhd df

hfh3fbbjlmkn sdfhdggwwrrwdfghjkmkmnjdfdggndfgjkkbkbl1232jvh1bbNavgjhgigation
driver.Navigate().GoToUrl("https://
translate.google.com");driver.Navigate().Refresh();driver.Navigate().Back();driver.
Navigate().Forward();driver.SwitchTo().Frame(element);

driver.FindElement(
selector
);By.Id("source")By.ClassName("city")By.Name("email")By.CssSelector("#cities")By.Ta
gName("header")By.XPath("//
input")By.LinkText("Contact")By.PartialLinkText("Contact")
Selectors
var selectElement =new
SelectElement(element);selectElement.SelectByText("2");selectElement.SelectByValue(
"2");selectElement.SelectByIndex(2);
SelectElement
element.Displayedelement.Enabledelement.Selectedelement.Textelement.Locationelement
.Sizeelement.TagNameelement.GetAttribute
(“name”)

Properties
element.SendKeys("cat");element.SendKeys(Keys.Enter)
Keyboard actions
element.Click()element.Submit()
Mouse actions
Actions action =new Actions(driver);var saveShortcut
=action.ContextClick(element).KeyDown(Keys.Control).SendKeys("S").Build();MoveByOff
set(offsetX, offset)MoveToElement(toElement)MoveToElement(toElement,
offsetX,offset)ClickAndHold()Release()ContextClick()DoubleClick()KeyDown(key)KeyUp(
key)SendKeys(keysToSend)Click(onElement)ClickAndHold(onElement)Release(onElement)Co
ntextClick(onElement)DoubleClick(onElement)DragAndDrop(source,
target)DragAndDropToOffset(source,offsetX, offsetY)KeyDown(element,
key)KeyUp(element, key)SendKeys(element, keysToSend)
Action combinations
var element = (IWebElement) ((IJavaScriptExecutor)driver).ExecuteScript("return $
('.city')[0]");
Using Java Script
var elements =driver.FindElements(selector)
Select multipleelements
var nestedElement =houseTile.FindElement(selector);
Select nestedelement

Selenium

WebDriver

You might also like