Skip to content

Instantly share code, notes, and snippets.

@chrisparnin
Created September 28, 2016 15:46
Show Gist options
  • Select an option

  • Save chrisparnin/e3ee1a96c681f12ae11246cfe3225182 to your computer and use it in GitHub Desktop.

Select an option

Save chrisparnin/e3ee1a96c681f12ae11246cfe3225182 to your computer and use it in GitHub Desktop.

Revisions

  1. chrisparnin revised this gist Sep 28, 2016. 1 changed file with 38 additions and 38 deletions.
    76 changes: 38 additions & 38 deletions SeleniumTestForSlack.java
    Original file line number Diff line number Diff line change
    @@ -1,39 +1,39 @@
    @Test
    public void postMessage()
    {
    driver.get("https://csc510-fall16.slack.com/");

    // Wait until page loads and we can see a sign in button.
    WebDriverWait wait = new WebDriverWait(driver, 30);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("signin_btn")));
    // Find email and password fields.
    WebElement email = driver.findElement(By.id("email"));
    WebElement pw = driver.findElement(By.id("password"));

    // Type in our test user login info.
    email.sendKeys("[email protected]");
    pw.sendKeys("****");

    // Click
    WebElement signin = driver.findElement(By.id("signin_btn"));
    signin.click();

    // Wait until we go to general channel.
    wait.until(ExpectedConditions.titleContains("general"));

    // Switch to #bots channel and wait for it to load.
    driver.get("https://csc510-fall16.slack.com/messages/bots");
    wait.until(ExpectedConditions.titleContains("bots"));

    // Type something
    WebElement messageBot = driver.findElement(By.id("message-input"));
    messageBot.sendKeys("hello world, from Selenium");
    messageBot.sendKeys(Keys.RETURN);

    wait.withTimeout(3, TimeUnit.SECONDS).ignoring(StaleElementReferenceException.class);

    WebElement msg = driver.findElement(
    By.xpath("//span[@class='message_body' and text() = 'hello world, from Selenium']"));
    assertNotNull(msg);
    @Test
    public void postMessage()
    {
    driver.get("https://csc510-fall16.slack.com/");

    // Wait until page loads and we can see a sign in button.
    WebDriverWait wait = new WebDriverWait(driver, 30);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("signin_btn")));

    // Find email and password fields.
    WebElement email = driver.findElement(By.id("email"));
    WebElement pw = driver.findElement(By.id("password"));

    // Type in our test user login info.
    email.sendKeys("[email protected]");
    pw.sendKeys("****");

    // Click
    WebElement signin = driver.findElement(By.id("signin_btn"));
    signin.click();

    // Wait until we go to general channel.
    wait.until(ExpectedConditions.titleContains("general"));

    // Switch to #bots channel and wait for it to load.
    driver.get("https://csc510-fall16.slack.com/messages/bots");
    wait.until(ExpectedConditions.titleContains("bots"));

    // Type something
    WebElement messageBot = driver.findElement(By.id("message-input"));
    messageBot.sendKeys("hello world, from Selenium");
    messageBot.sendKeys(Keys.RETURN);

    wait.withTimeout(3, TimeUnit.SECONDS).ignoring(StaleElementReferenceException.class);

    WebElement msg = driver.findElement(
    By.xpath("//span[@class='message_body' and text() = 'hello world, from Selenium']"));
    assertNotNull(msg);
    }
  2. chrisparnin created this gist Sep 28, 2016.
    39 changes: 39 additions & 0 deletions SeleniumTestForSlack.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    @Test
    public void postMessage()
    {
    driver.get("https://csc510-fall16.slack.com/");

    // Wait until page loads and we can see a sign in button.
    WebDriverWait wait = new WebDriverWait(driver, 30);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("signin_btn")));

    // Find email and password fields.
    WebElement email = driver.findElement(By.id("email"));
    WebElement pw = driver.findElement(By.id("password"));

    // Type in our test user login info.
    email.sendKeys("[email protected]");
    pw.sendKeys("****");

    // Click
    WebElement signin = driver.findElement(By.id("signin_btn"));
    signin.click();

    // Wait until we go to general channel.
    wait.until(ExpectedConditions.titleContains("general"));

    // Switch to #bots channel and wait for it to load.
    driver.get("https://csc510-fall16.slack.com/messages/bots");
    wait.until(ExpectedConditions.titleContains("bots"));

    // Type something
    WebElement messageBot = driver.findElement(By.id("message-input"));
    messageBot.sendKeys("hello world, from Selenium");
    messageBot.sendKeys(Keys.RETURN);

    wait.withTimeout(3, TimeUnit.SECONDS).ignoring(StaleElementReferenceException.class);

    WebElement msg = driver.findElement(
    By.xpath("//span[@class='message_body' and text() = 'hello world, from Selenium']"));
    assertNotNull(msg);
    }