Advertisement
Guest User

SendMessage (vk.com)

a guest
Oct 23rd, 2013
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.94 KB | None | 0 0
  1. package Selenium;
  2.  
  3. import org.junit.*;
  4. import com.thoughtworks.selenium.*;
  5. import static org.junit.Assert.*;
  6.  
  7. public class SendMessage {
  8.     private Selenium selenium;
  9.  
  10.     @Before
  11.     public void setUp() throws Exception {
  12.         selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://vk.com/");
  13.         selenium.start();
  14.     }
  15.  
  16.     @Test
  17.     public void testSendMessage() throws Exception {
  18.         selenium.open("/");
  19.         selenium.type("id=quick_email", "<email>");
  20.         selenium.type("id=quick_pass", "<password>");
  21.         selenium.click("id=quick_login_button");
  22.         for (int second = 0;; second++) {
  23.             if (second >= 60) fail("timeout");
  24.             try { if (selenium.isElementPresent("//li[@id='l_msg']/a/span[2]")) break; } catch (Exception e) {}
  25.             Thread.sleep(1000);
  26.         }
  27.  
  28.         selenium.click("//li[@id='l_msg']/a/span[2]");
  29.         selenium.waitForPageToLoad("30000");
  30.         selenium.click("class=input_back_content");
  31.         selenium.type("id=im_filter", "<имя или фамилия>");
  32.         selenium.click("id=im_friend<id друга>");
  33.         selenium.waitForPageToLoad("30000");
  34.         selenium.isElementPresent("//div[@id='im_txt_wrap<id друга>']");
  35.         //кусок ненужного кода
  36.         if (selenium.isElementPresent("//div[@id='im_peer_controls']")) {
  37.             System.out.println("Element was found");
  38.         } else {
  39.             fail();
  40.         }
  41.         //кусок ненужного кода
  42.         if (selenium.isElementPresent("//div[@id='im_editable<id друга>'][@class='im_editable']")) {
  43.             System.out.println("Element was found");
  44.         } else {
  45.             fail();
  46.         }
  47.        
  48.         //selenium.click("//div[@id='im_editable5217047'][@class='im_editable']");
  49.         selenium.type("//div[@id='im_editable<id друга>'][@class='im_editable']", "Test Hello!");
  50.         //selenium.type("//div[@id='im_txt_wrap5217047']", "Hello!");
  51.         selenium.click("id=im_send");
  52.         selenium.click("id=logout_link");
  53.         selenium.waitForPageToLoad("30000");
  54.     }
  55.  
  56.     @After
  57.     public void tearDown() throws Exception {
  58.         selenium.stop();
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement