Piyush900 / SurveyGameAristocrat

Sevya Multimedia
0 stars 0 forks source link

Sevya Multimedia #1

Open Piyush900 opened 8 years ago

Piyush900 commented 8 years ago

package SurveyGamez;

import java.awt.AWTException; import java.awt.Desktop.Action; import java.awt.datatransfer.StringSelection; import java.awt.Robot; import java.awt.Toolkit; import java.awt.Event; import java.util.concurrent.TimeUnit;

import org.junit.BeforeClass; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.interactions.Actions; import org.testng.annotations.BeforeMethod;

import com.thoughtworks.selenium.webdriven.commands.KeyEvent;

import org.testng.annotations.*;

public class Surveygamezz1 {

public ChromeDriver driver;

/*@BeforeMethod
public static void Beforemethod()
{
    System.setProperty("webdriver.chrome.driver","C:\\Users\\piyush\\workspace\\SurveyTrail\\Lib\\chromedriver.exe");
    ChromeDriver driver=new ChromeDriver();
    driver.get("http://stg.surveygamez.com/sgs/login?");
}*/

@Test
public void Test() throws InterruptedException, AWTException

{
    System.setProperty("webdriver.chrome.driver","C:\\Users\\piyush\\workspace\\SurveyTrail\\Lib\\chromedriver.exe");
    ChromeDriver driver=new ChromeDriver();
    driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);

    driver.get("http://stg.surveygamez.com/login?");
    //driver.findElementByCssSelector("html body.sgs-bkgrnd div.container div.jumbotron form#loginForm div.form-group input#email.form-control").sendKeys("piyush.mishra90@gmail.com");
    //driver.findElementByXPath("/html/body/div[3]/div[2]/form/div[1]/input").sendKeys("piyush.mishra90@gmail.com");
    driver.findElementById("email").sendKeys("piyush.mishra@sevyamultimedia.com");
    driver.findElementById("pwd").sendKeys("P@iyush90");
    Thread.sleep(2000);

    //Welcome 

    driver.findElementByXPath("/html/body/div[3]/div[2]/form/button").click();//sign in
    Thread.sleep(2000);
    driver.findElementByCssSelector("html body.fuelux div.container div.row div.col-xs-9 div.row form#command div.col-xs-3 button.btn.btn-primary").click();
    //driver.findElementByXPath("/html/body/div[6]/div/div[2]/div/div/div/div/div[1]/div[2]/div/form/div[1]/input").sendKeys("Hello World");
    Thread.sleep(2000);
    driver.findElementByCssSelector("html body.fuelux div.container div.col-xs-8.col-xs-offset-2 div.step-content div.step-pane.active.sample-pane div.row div.col-xs-12 div#accordion.panel-group div.panel.panel-default div#collapse1.panel-collapse.collapse.in div.panel-body form#surveyForm.bv-form div.form-group.has-feedback input#surveyTitle.form-control.surveyName").sendKeys("Hello");
    Thread.sleep(2000);
    driver.findElementByXPath("/html/body/div[8]/div/div[2]/div/div/div/div/div[1]/div[2]/div/form/div[2]/button").click();
    Thread.sleep(20000);
    Actions act = new Actions(driver);
//  act.dragAndDrop(driver.findElementByXPath("/html/body/div[3]/div[2]/div[1]/div[2]/ul/li[1]/a/div/span"),(driver.findElementByXPath("/html/body/div[3]/div[2]/div[2]/div/div[1]/center/h3/small")));
  //  act.dragAndDrop(driver.findElement(By.cssSelector("html body.fuelux div#list-questions div div.col-xs-3 div.panel.panel-primary ul.list-group.list-group-questiontype li.list-group-box a.list-group-item.list-group-item-small.question-type div.draggable-items.question-dragitem.ui-draggable.ui-draggable-handle span"));
      act.dragAndDrop(driver.findElementByCssSelector("html body.fuelux div#list-questions div div.col-xs-3 div.panel.panel-primary ul.list-group.list-group-questiontype li.list-group-box a.list-group-item.list-group-item-small.question-type div.draggable-items.question-dragitem.ui-draggable.ui-draggable-handle span"), driver.findElementByCssSelector("html body.fuelux div#list-questions div div.col-xs-9.well.well-lg.overflowscroll.min-container-all div#question_area.question-list.connected div.list-group.connected.ui-sortable.questionlist.welcome-question.question-container center.drag-head.ui-sortable-handle h3 small")).build().perform();

      Thread.sleep(10000);
      driver.findElementById("isAddImage").click();
      //driver.findElementByCssSelector("html body.fuelux div#list-questions div div.col-xs-9.well.well-lg.overflowscroll.min-container-all div#question_area.question-list.connected div.list-group.connected.ui-sortable.questionlist.welcome-question.question-container div#897b64d1.questionContent.panel-body.pull-center.panel.panel-default div#informationQuestionTab.questionTab div.tab-content div#edit1.tab-pane.active form#welcomeQuestionForm div.col-xs-12.text-muted.text-muted-less-margin div.col-xs-5 div.form-group div.btn-group.lead button#isAddImage.btn.btn-default.image-button").click();
      Thread.sleep(2000);
      //driver.findElementByCssSelector("html body.fuelux div#list-questions div div.col-xs-9.well.well-lg.overflowscroll.min-container-all div#question_area.question-list.connected div.list-group.connected.ui-sortable.questionlist.welcome-question.question-container div#897b64d1.questionContent.panel-body.pull-center.panel.panel-default div#informationQuestionTab.questionTab div.tab-content div#edit1.tab-pane.active form#welcomeQuestionForm div.col-xs-12.text-muted.text-muted-less-margin div.col-xs-5 div.form-group div#image-assist-thumbnail div#17.button-no-padding.question-image a#assist-background-popover.btn.btn-default.button-no-padding.background-popover img#assist-background-thumbnail-url.assist-background-thumbnail-url").click();
      driver.findElementById("assist-background-thumbnail-url").click();
      Thread.sleep(2000);
      driver.findElementByXPath("/html/body/div[5]/div[2]/div[2]/div/div[1]/div/div[2]/div/div[1]/form/div[3]/div[2]/div/div[3]/div[1]/div/div[2]/center/button").click();
     // driver.findElementByXPath("/html/body/div[3]/div[2]/div[2]/div/div[1]/div/div[2]/div/div[1]/form/div[3]/div[2]/div/div[3]/div[1]/div/div[2]/center/button").click();
      //driver.findElementByCssSelector("html body.fuelux div#list-questions div div.col-xs-9.well.well-lg.overflowscroll.min-container-all div#question_area.question-list.connected div.list-group.connected.ui-sortable.questionlist.welcome-question.question-container div#897b64d1.questionContent.panel-body.pull-center.panel.panel-default div#informationQuestionTab.questionTab div.tab-content div#edit1.tab-pane.active form#welcomeQuestionForm div.col-xs-12.text-muted.text-muted-less-margin div.col-xs-5 div.form-group div#image-assist-thumbnail div#17.button-no-padding.question-image div#popover735676.popover.fade.left.in div.popover-content center button.btn.btn-primary.btn-sm.upload-media").click();
      Thread.sleep(2000);
     // driver.findElementByCssSelector("html body.fuelux div#list-questions div div.col-xs-9.well.well-lg.overflowscroll.min-container-all div#question_area.question-list.connected div.list-group.connected.ui-sortable.questionlist.welcome-question.question-container div#cab3018a.questionContent.panel-body.pull-center.panel.panel-default div#informationQuestionTab.questionTab div.tab-content div#edit1.tab-pane.active form#welcomeQuestionForm div.col-xs-12.text-muted.text-muted-less-margin div.col-xs-5 div.form-group div#image-assist-thumbnail div#17.button-no-padding.question-image div#popover554657.popover.fade.left.in div.popover-content center button.btn.btn-primary.btn-sm.upload-media").click();
     // driver.findElementByXPath("/html/body/div[5]/div[2]/div[2]/div/div[1]/div/div[2]/div/div[1]/form/div[3]/div[2]/div/div[3]/div[1]/div/div[2]/center/button").click();
     driver.findElementByXPath("/html/body/div[6]/div/div/div[2]/form/div[1]/input[1]").click();
      //driver.findElementByCssSelector("html body.fuelux.modal-open div.modal.fade.update-media.in div.modal-dialog div.modal-content div.modal-body form#UploadForm div.form-group.col-xs-12 input#imageFile.form-control.fileInputBox").click();
      Thread.sleep(2000);
     /* WebElement frame =driver.switchTo().activeElement();
      frame.sendKeys("C:\\Users\\piyush\\Desktop\\Flash Issues\\a.jpg");*/

// Upload image
StringSelection s=new StringSelection("C:\Users\piyush\Desktop\SurveyGamez\Eclipse\Pics\pics.jpg"); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(s,null);

      Robot robot = new Robot();
      Thread.sleep(1000);
       robot.keyPress(java.awt.event.KeyEvent.VK_ENTER);
       robot.keyRelease(java.awt.event.KeyEvent.VK_ENTER);
       robot.keyPress(java.awt.event.KeyEvent.VK_CONTROL);
       robot.keyPress(java.awt.event.KeyEvent.VK_V);

       robot.keyRelease(java.awt.event.KeyEvent.VK_CONTROL);
       robot.keyRelease(java.awt.event.KeyEvent.VK_V);
       Thread.sleep(1000);

       robot.keyPress(java.awt.event.KeyEvent.VK_ENTER);
       robot.keyRelease(java.awt.event.KeyEvent.VK_ENTER);
         Thread.sleep(2000);
       // Click Upload button  
     driver.findElementByCssSelector("html body.fuelux.modal-open div.modal.fade.update-media.in div.modal-dialog div.modal-content div.modal-body form#UploadForm input.btn.btn-primary").click();

    // C:\Users\piyush\Desktop\SurveyGamez\Eclipse\Pics\pics.jpg

      Thread.sleep(2000);

driver.findElementByXPath("/html/body/div[5]/div[2]/div[2]/div/div[1]/div/div[2]/div/div[1]/form/div[3]/div[1]/div/div[2]/textarea").sendKeys("Which Automation Tool is best ?"); // driver.findElementByXPath("/html/body/div[3]/div[2]/div[2]/div/div[1]/div/div[2]/div/div[1]/form/div[3]/div[1]/div/div[2]/textarea").sendKeys("Which Automation Tool is best ?"); // driver.findElementByCssSelector("html body.fuelux div#list-questions div div.col-xs-9.well.well-lg.overflowscroll.min-container-all div#question_area.question-list.connected div.list-group.connected.ui-sortable.questionlist.welcome-question.question-container div#6d62f41d.questionContent.panel-body.pull-center.panel.panel-default div#informationQuestionTab.questionTab div.tab-content div#edit1.tab-pane.active form#welcomeQuestionForm div.col-xs-12.text-muted.text-muted-less-margin div.col-xs-7 div.form-group div.text-muted.text-muted-less-margin textarea#question-verbiage.form-control").sendKeys("Which automation tool is best"); Thread.sleep(2000); driver.findElementByXPath("/html/body/div[5]/div[2]/div[2]/div/div[1]/div/div[2]/div/div[1]/form/div[3]/div[1]/div/div[6]/textarea").sendKeys("Selenium is the best Automation tools"); //driver.findElementByXPath("/html/body/div[3]/div[2]/div[2]/div/div[1]/div/div[2]/div/div[1]/form/div[3]/div[1]/div/div[6]/textarea").sendKeys("Selenium is the best Automation tools"); Thread.sleep(2000); // driver.findElementByXPath("/html/body/div[3]/div[2]/div[2]/div/div[1]/div/div[2]/button[1]").isSelected(); //driver.findElement(By.name("Save")).sendKeys(Keys.ENTER); driver.findElementByXPath("/html/body/div[5]/div[2]/div[2]/div/div[1]/div/div[2]/button[1]").sendKeys(Keys.ENTER);

     //Multiple Choice

     act.dragAndDrop(driver.findElementByXPath("/html/body/div[5]/div[2]/div[1]/div[2]/ul/li[4]/a/div"), driver.findElementByXPath("/html/body/div[5]/div[2]/div[2]/div/div[2]/div")).build().perform();

     Thread.sleep(2000);

    driver.findElementByXPath("/html/body/div[5]/div[2]/div[2]/div/div[2]/div/div/div[2]/div/div[1]/form/div[3]/div[1]/div[1]/div[2]/textarea").sendKeys("Which is the automation tool");
    Thread.sleep(2000);
    driver.findElementByXPath("/html/body/div[5]/div[2]/div[2]/div/div[2]/div/div/div[2]/div/div[1]/form/div[3]/div[1]/div[1]/div[6]/textarea").sendKeys("automation is the use to control the execution of tests and the comparison of actual outcomes with predicted outcomes.");
    Thread.sleep(2000);

    driver.findElementByXPath("/html/body/div[5]/div[2]/div[2]/div/div[2]/div/div/div[2]/div/div[1]/form/div[3]/div[2]/div/div[2]/div[1]/button[1]").click();
    Thread.sleep(2000);

    driver.findElementByXPath("/html/body/div[5]/div[2]/div[2]/div/div[2]/div/div/div[2]/div/div[1]/form/div[3]/div[2]/div/div[3]/div[1]/a/img").click();
    Thread.sleep(2000);

    driver.findElementByXPath("/html/body/div[5]/div[2]/div[2]/div/div[2]/div/div/div[2]/div/div[1]/form/div[3]/div[2]/div/div[3]/div[1]/div/div[2]/center/button").click();
    Thread.sleep(2000);

    driver.findElementByXPath("/html/body/div[6]/div/div/div[2]/form/div[1]/input[1]").click();
    Thread.sleep(2000);

    driver.findElementByXPath("/html/body/div[5]/div[2]/div[2]/div/div[2]/div/div/div[2]/div/div[1]/form/table/tbody/tr[1]/td[1]/input").sendKeys("Selenium");
    driver.findElementByXPath("/html/body/div[5]/div[2]/div[2]/div/div[2]/div/div/div[2]/div/div[1]/form/table/tbody/tr[2]/td[1]/input").sendKeys("Java");
    driver.findElementById("optionsText2").click();
    driver.findElementByXPath("/html/body/div[5]/div[2]/div[2]/div/div[2]/div/div/div[2]/div/div[1]/form/table/tbody/tr[3]/td[1]/input").sendKeys("C");

    StringSelection s1=new StringSelection("C:\\Users\\piyush\\Desktop\\SurveyGamez\\Eclipse\\Pics\\pics.jpg");
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(s1,null);

    Robot robot1 = new Robot();
    Thread.sleep(1000);
     robot1.keyPress(java.awt.event.KeyEvent.VK_ENTER);
     robot1.keyRelease(java.awt.event.KeyEvent.VK_ENTER);
     robot1.keyPress(java.awt.event.KeyEvent.VK_CONTROL);
     robot1.keyPress(java.awt.event.KeyEvent.VK_V);

     robot1.keyRelease(java.awt.event.KeyEvent.VK_CONTROL);
     robot1.keyRelease(java.awt.event.KeyEvent.VK_V);
     Thread.sleep(1000);

     robot1.keyPress(java.awt.event.KeyEvent.VK_ENTER);
     robot1.keyRelease(java.awt.event.KeyEvent.VK_ENTER);
       Thread.sleep(2000);

       driver.findElementByXPath("/html/body/div[6]/div/div/div[2]/form/input").click();

}

}

Piyush900 commented 8 years ago

4-12-2015