Skip to content

Instantly share code, notes, and snippets.

View angelovstanton's full-sized avatar
💭
UPDATED STATUS

Anton Angelov angelovstanton

💭
UPDATED STATUS
View GitHub Profile
// <copyright file="BlobStorageService.cs" company="Automate The Planet Ltd.">
// Copyright 2021 Automate The Planet Ltd.
// Unauthorized copying of this file, via any medium is strictly prohibited
// Proprietary and confidential
// </copyright>
// <author>Anton Angelov</author>
// <site>https://bellatrix.solutions/</site>
using System;
using System.Collections.Generic;
using System;
public class Program
{
public static void Main()
{
Console.WriteLine("Hello Sukhpinder!");
}
}
@Test
public void VerifyFileDownloadChrome() throws IOException {
var expectedFilePath = Paths.get("c:\\temp\\Testing_Framework_2015_3_1314_2_Free.exe");
try
{
driver.navigate().to("https://www.telerik.com/download-trial-file/v2/telerik-testing-framework");
wait.until(x -> Files.exists(expectedFilePath));
long bytes = Files.size(expectedFilePath);
Assert.assertEquals(4326192, bytes);
String downloadFilepath = "c:\\temp";
HashMap<String, Object> chromePrefs = new HashMap<>();
chromePrefs.put("profile.default_content_settings.popups", 0);
chromePrefs.put("download.default_directory", downloadFilepath);
chromeOptions.setExperimentalOption("prefs", chromePrefs);
chromeOptions.addArguments("--test-type");
chromeOptions.addArguments("start-maximized", "disable-popup-blocking");
private void waitForAjaxComplete() {
wait.until(x ->
{
JavascriptExecutor javascriptExecutor = (JavascriptExecutor) driver;
Boolean isAjaxCallComplete =
(Boolean)javascriptExecutor.executeScript("return window.jQuery != undefined && jQuery.active == 0");
return isAjaxCallComplete ;
});
}
@Test
public void setHiddenField() {
//<input type="hidden" name="country" value="Bulgaria"/>
var theHiddenElem = driver.findElement(By.name("country"));
JavascriptExecutor javascriptExecutor = (JavascriptExecutor) driver;
javascriptExecutor.executeScript("arguments[0].value='Germany';", theHiddenElem);
String hiddenFieldValue = theHiddenElem.getAttribute("value");
Assert.assertEquals("Germany", hiddenFieldValue);
@Test
public void assertButtonEnabledDisabled() {
driver.navigate().to("http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_button_disabled");
driver.switchTo().frame("iframeResult");
var button = driver.findElement(By.xpath("/html/body/button"));
Assert.assertFalse(button.isEnabled());
}
@Test
public void focusOnControl() {
driver.navigate().to("http://automatetheplanet.com/");
waitUntilLoaded();
var ourMissionLink = driver.findElement(By.xpath("//*[@id=\"panel-6435-0-0-4\"]/div"));
Actions action = new Actions(driver);
action.moveToElement(ourMissionLink).build().perform();
}
@Test
public void scrollFocusToControl() {
driver.navigate().to("http://automatetheplanet.com/");
var ourMissionLink = driver.findElement(By.xpath("//*[@id=\"panel-6435-0-0-4\"]/div"));
String jsToBeExecuted = String.format("window.scroll(0, {0});", ourMissionLink.getLocation().getY());
JavascriptExecutor javascriptExecutor = (JavascriptExecutor) driver;
javascriptExecutor.executeScript(jsToBeExecuted);
}
@Test
public void scrollFocusToControl() {
driver.navigate().to("http://automatetheplanet.com/");
var ourMissionLink = driver.findElement(By.xpath("//*[@id=\"panel-6435-0-0-4\"]/div"));
String jsToBeExecuted = String.format("window.scroll(0, {0});", ourMissionLink.getLocation().getY());
JavascriptExecutor javascriptExecutor = (JavascriptExecutor) driver;
javascriptExecutor.executeScript(jsToBeExecuted);
}