Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Selenium;
- import org.junit.*;
- import com.thoughtworks.selenium.*;
- import static org.junit.Assert.*;
- public class SendMessage {
- private Selenium selenium;
- @Before
- public void setUp() throws Exception {
- selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://vk.com/");
- selenium.start();
- }
- @Test
- public void testSendMessage() throws Exception {
- selenium.open("/");
- selenium.type("id=quick_email", "<email>");
- selenium.type("id=quick_pass", "<password>");
- selenium.click("id=quick_login_button");
- for (int second = 0;; second++) {
- if (second >= 60) fail("timeout");
- try { if (selenium.isElementPresent("//li[@id='l_msg']/a/span[2]")) break; } catch (Exception e) {}
- Thread.sleep(1000);
- }
- selenium.click("//li[@id='l_msg']/a/span[2]");
- selenium.waitForPageToLoad("30000");
- selenium.click("class=input_back_content");
- selenium.type("id=im_filter", "<имя или фамилия>");
- selenium.click("id=im_friend<id друга>");
- selenium.waitForPageToLoad("30000");
- selenium.isElementPresent("//div[@id='im_txt_wrap<id друга>']");
- //кусок ненужного кода
- if (selenium.isElementPresent("//div[@id='im_peer_controls']")) {
- System.out.println("Element was found");
- } else {
- fail();
- }
- //кусок ненужного кода
- if (selenium.isElementPresent("//div[@id='im_editable<id друга>'][@class='im_editable']")) {
- System.out.println("Element was found");
- } else {
- fail();
- }
- //selenium.click("//div[@id='im_editable5217047'][@class='im_editable']");
- selenium.type("//div[@id='im_editable<id друга>'][@class='im_editable']", "Test Hello!");
- //selenium.type("//div[@id='im_txt_wrap5217047']", "Hello!");
- selenium.click("id=im_send");
- selenium.click("id=logout_link");
- selenium.waitForPageToLoad("30000");
- }
- @After
- public void tearDown() throws Exception {
- selenium.stop();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement