Created
February 5, 2017 13:08
-
-
Save angelovstanton/1f97ee7c4a261c9f6f81f14e59d49f92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Drag and Drop | |
IWebElement element = | |
driver.FindElement(By.XPath("//*[@id='project']/p[1]/div/div[2]")); | |
Actions move = new Actions(driver); | |
move.DragAndDropToOffset(element, 30, 0).Perform(); | |
// How to check if an element is visible | |
Assert.IsTrue(driver.FindElement(By.XPath("//*[@id='tve_editor']/div")).Displayed); | |
// Upload a file | |
IWebElement element = driver.FindElement(By.Id("RadUpload1file0")); | |
String filePath = @"D:\WebDriver.Series.Tests\\WebDriver.xml"; | |
element.SendKeys(filePath); | |
// Scroll focus to control | |
IWebElement link = driver.FindElement(By.PartialLinkText("Previous post")); | |
string js = string.Format("window.scroll(0, {0});", link.Location.Y); | |
((IJavaScriptExecutor)driver).ExecuteScript(js); | |
link.Click(); | |
// Taking an element screenshot | |
IWebElement element = driver.FindElement(By.XPath("//*[@id='tve_editor']/div")); | |
var cropArea = new Rectangle(element.Location, element.Size); | |
var bitmap = bmpScreen.Clone(cropArea, bmpScreen.PixelFormat); | |
bitmap.Save(fileName); | |
// Focus on a control | |
IWebElement link = driver.FindElement(By.PartialLinkText("Previous post")); | |
// Wait for visibility of an element | |
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); | |
wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy( | |
By.XPath("//*[@id='tve_editor']/div[2]/div[2]/div/div"))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment