Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.tests;
- import com.thoughtworks.selenium.*;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
- import static org.junit.Assert.*;
- import java.util.regex.Pattern;
- public class softunitest {
- private Selenium selenium;
- private String[] users;
- @Before
- public void setUp() throws Exception {
- selenium = new DefaultSelenium("localhost", 4444, "*chrome", "https://softuni.bg/");
- selenium.start();
- users = new String[] { "zontak", "RoYaL", "wartus", "aluin" };
- }
- @Test
- public void testSoftunitest() throws Exception {
- for (int i = 0; i < 1000; i++) {
- selenium.open("https://softuni.bg/");
- selenium.click("id=search-input");
- selenium.type("id=search-input", users[i]);
- selenium.click("//form[@id='search-form']/button");
- selenium.waitForPageToLoad("30000");
- if (selenium.isElementPresent(
- selenium.click("//div/a/span");
- selenium.waitForPageToLoad("30000");
- }
- }
- private void click(String element) {
- if (this.selenium.isElementPresent(element) {
- this.selenium.click(element);
- } else {
- this.click(element);
- }
- }
- @After
- public void tearDown() throws Exception {
- selenium.stop();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement