Skip to content

Instantly share code, notes, and snippets.

@mknorth
Last active December 11, 2017 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mknorth/f73d7c0338d632dcb8693b6c8e0ffb64 to your computer and use it in GitHub Desktop.
Save mknorth/f73d7c0338d632dcb8693b6c8e0ffb64 to your computer and use it in GitHub Desktop.
HomeWork
package homework1;
//логинит на Фейсбук и выводит титул и надпись на загруженной картинке
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class FacebookExamXPath {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:/webDrivers/chromedriver.exe");
WebDriver dr = new ChromeDriver();
dr.get("https://www.facebook.com/");
dr.findElement(By.xpath("//input[@id='email']")).clear();
dr.findElement(By.xpath("//input[@id='email']")).sendKeys("ronpotato@ukr.net");
dr.findElement(By.xpath("//input[@id='pass']")).clear();
dr.findElement(By.xpath("//input[@id='pass']")).sendKeys("4587393t");
// dr.findElement(By.xpath("//input[@id='pass']")).sendKeys(Keys.ENTER);
//сделал без sendKey, а через нажатие кнопки логина
WebElement loginButton = dr.findElement(By.xpath("//label[@id='loginbutton']"));
loginButton.click();
// //вроде бы лучше чем метод click так как ничего не принимает и не отдает
// WebElement loginButton = dr.findElement(By.xpath("//label[@id='loginbutton']"));
// loginButton.submit();
System.out.println(dr.getTitle());
System.out.println(dr.findElement(By.xpath("//span[@class='_5z6m']")).getText());
dr.quit();
}
}
package homework1;
//задача считывает Имя с презентации
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Namefounder {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:/webDrivers/chromedriver.exe");
WebDriver dri = new ChromeDriver();
dri.get("https://docs.google.com/presentation/d/1Epf_2HQ86EgQFkqiB3zz2Uq08MkDlDCmU7poR-0-brs/edit#slide=id.p");
System.out.print(dri.findElement(By.id("editor-g1025d2f9cf_0_283")).getText());
dri.quit();
}
}
package lesson1;
//задача считывает Имя с консоли и выводит приветствие
import java.util.Scanner;
public class Scan {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter your name:");
String s = scanner.nextLine();
System.out.println("Greetings, " + s + "!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment