Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrei Solntsev asolntsev

View GitHub Profile
View TextOfLength.java
@Test
public void test42() {
$("#random-username").shouldHave(new TextOfLength(42));
}
private static class TextOfLength extends Condition {
private final int expectedLength;
public TextOfLength(int expectedLength) {
View selenide.log
[main] DEBUG com.codeborne.selenide.webdriver.WebDriverFactory - browserSize=1366x768
[main] DEBUG com.codeborne.selenide.webdriver.WebDriverFactory - startMaximized=false
[main] DEBUG com.codeborne.selenide.webdriver.WebDriverFactory - downloadsFolder=/Users/andrei/projects/selenide/.idea/modules/build/downloads/1621357375904_75212_1
[main] INFO io.github.bonigarcia.wdm.WebDriverManager - Using chromedriver 90.0.4430.24 (resolved driver for Chrome 90)
[main] INFO io.github.bonigarcia.wdm.WebDriverManager - Exporting webdriver.chrome.driver as /Users/andrei/.cache/selenium/chromedriver/mac64/90.0.4430.24/chromedriver
View SearchByTextTest.java
import org.junit.jupiter.api.Test;
import static com.codeborne.selenide.Condition.text;
import static com.codeborne.selenide.Selectors.byText;
import static com.codeborne.selenide.Selectors.byXpath;
import static com.codeborne.selenide.Selectors.withText;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.open;
final class SearchByTextTest {
View LogBrowserLogs.java
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
import org.openqa.selenium.logging.LogEntries;
import org.openqa.selenium.logging.LogEntry;
import org.openqa.selenium.logging.LogType;
import org.openqa.selenium.logging.Logs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
View HangingTest.java
package org.selenide.examples;
import com.codeborne.selenide.Configuration;
import com.codeborne.selenide.Selenide;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import static com.codeborne.selenide.Condition.visible;
@asolntsev
asolntsev / AppiumScrollTest.kt
Last active Sep 29, 2020
How to scroll in Appium
View AppiumScrollTest.kt
// Will be added to https://github.com/selenide/selenide-appium soon
// helper class
data class ScrollBy(val uiSelector: String) {
companion object {
fun toId(id: String) = ScrollBy("new UiSelector().resourceIdMatches(\".*id/$id\")")
fun toText(text: String) = ScrollBy("new UiSelector().text(\"${text}\")")
}
}
View CDP-get-downloaded-file-body
import com.codeborne.selenide.WebDriverRunner;
import com.github.kklisura.cdt.protocol.commands.Network;
import com.github.kklisura.cdt.protocol.types.network.Request;
import com.github.kklisura.cdt.services.ChromeDevToolsService;
import com.github.kklisura.cdt.services.ChromeService;
import com.github.kklisura.cdt.services.impl.ChromeServiceImpl;
import com.github.kklisura.cdt.services.types.ChromeTab;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Capabilities;
View AccountTest.java
public class AccountTest {
public static void main(String[] args) {
Account account = new Account("111-22-33-4444");
System.out.println("Остаток на счету " + account.number + ": " + account.getBalance());
account.pay(3);
System.out.println("Остаток на счету " + account.number + ": " + account.getBalance());
}
}
View AnimalsTest.java
public class AnimalsTest {
public static void main(String[] args) {
Cat cat = new Cat("Tom", 8);
Mouse mouse = new Mouse("Jerry", 3);
System.out.println("Cat name is: " + cat.getName());
System.out.println("Mouse name is: " + mouse.getName());
System.out.println("Mouse weight is: " + mouse.weight);
}
}
View FileTest.java
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
public class FileTest {
public static void main(String[] args) throws IOException {
int[] numbers = new int[] {1,2,3,4,5};
try (PrintWriter writer = new PrintWriter(new FileWriter("zopa.txt"))) {
for (int number : numbers) {