DWQA Ask QuestionCategory: QuestionsAssignment: Complete all the Operations using Actions for Site jqueryUI.com
admin Staff asked 5 years ago

Perform all the Operations on site: https://jqueryui.com/

  1. Draggable
  2. Droppable
  3. Resizable
  4. Selectable
  5. Sortable
  6. AutoComplete
  7. CheckBox Radio
  8. Control Group
  9. Date Picker
  10. Dialog
  11. Menu
  12. Select Menu
  13. Slider
  14. Spinner as Alert and Handling Enable and Disabled
  15. Tooltip
31 Answers
Suraj Gaikwad Staff answered 5 years ago

Draggable functionality code

WebElement draggable_text_link = driver.findElement(By.xpath("//li//a[text()='Draggable']")); 
draggable_text_link.click(); 

//switching in another frame 
WebElement frame = driver.findElement(By.xpath("//iframe[@class='demo-frame']"));
driver.switchTo().frame(frame);

WebElement drag_me_around_box = driver.findElement(By.xpath("//div[@class='ui-widget-content ui-draggable ui-draggable-handle']"));

Actions action = new Actions(driver);
action.dragAndDropBy(drag_me_around_box, 200, 0).perform();

 

 

 

Suraj Gaikwad Staff answered 5 years ago

Droppable Functionality code

//clicking on droppable link text
WebElement droppable_text_link = driver.findElement(By.xpath("//li//a[text()='Droppable']"));
droppable_text_link.click();

//switching into another frame
WebElement frame = driver.findElement(By.xpath("//iframe[@class='demo-frame']"));
driver.switchTo().frame(frame);

WebElement source_box = driver.findElement(By.xpath("//div[@class='ui-widget-content ui-draggable ui-draggable-handle']"));

WebElement destination_box = driver.findElement(By.xpath("//div[@class='ui-widget-header ui-droppable']"));

Actions actions = new Actions(driver);
actions.dragAndDrop(source_box, destination_box).perform();

 

 

 

 

Suraj Gaikwad Staff answered 5 years ago

Resizable functionality code

Start your code here//clicking on resizable text link
WebElement resizable_text_link = driver.findElement(By.xpath("//li//a[text()='Resizable']"));
resizable_text_link.click();

WebElement frame = driver.findElement(By.xpath("//iframe[@class='demo-frame']"));
driver.switchTo().frame(frame);

WebElement resizable_point = driver.findElement(By.xpath("//div[@class='ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se']"));

Actions actions = new Actions(driver);
actions.clickAndHold(resizable_point).dragAndDropBy(resizable_point, 100, 100).perform();

 

 

 

 

 

Suraj Gaikwad Staff answered 5 years ago

Selectable functionality code

WebElement selectable_text_link = driver.findElement(By.xpath("//li//a[text()='Selectable']"));
selectable_text_link.click();

WebElement frame = driver.findElement(By.className("demo-frame"));
driver.switchTo().frame(frame);

WebElement item1 = driver.findElement(By.xpath("//li[@class='ui-widget-content ui-selectee' and text()='Item 1']"));

String s1=item1.getAttribute("class");
item1.click();
String s2=item1.getAttribute("class");

// validation
 
if(s1.equals(s2))
 {
 System.out.println("not selectable");
 }
 else
 {
 System.out.println("selectable");
 }


 

 

 

 

 

 

 

 

Suraj Gaikwad Staff answered 5 years ago

Sortable functionality code

WebElement sortable_text_link = driver.findElement(By.linkText("Sortable"));
sortable_text_link.click();

WebElement iframe = driver.findElement(By.className("demo-frame"));
driver.switchTo().frame(iframe);
Thread.sleep(4000);

WebElement item1 = driver.findElement(By.xpath("//li[@class='ui-state-default ui-sortable-handle' and text()='Item 1']"));

Actions actions = new Actions(driver);
actions.clickAndHold(item1).dragAndDropBy(item1, 0, 50).build().perform();

 

 

 

 

 

Suraj Gaikwad Staff answered 5 years ago

Autocomplete functionality code

WebElement autocomplete_text_link = driver.findElement(By.xpath("//li//a[text()='Autocomplete']"));
autocomplete_text_link.click();

WebElement iframe = driver.findElement(By.xpath("//iframe[@class='demo-frame']"));
driver.switchTo().frame(iframe);

WebElement text_box = driver.findElement(By.xpath("//input[@class='ui-autocomplete-input']")); 
text_box.sendKeys("p");

List<WebElement> list_of_suggetions = driver.findElements(By.xpath("//div[@class='ui-menu-item-wrapper']"));

for(WebElement list : list_of_suggetions)
 {
  if(list.getText().equals("AppleScript"))
         {
                list.click();
         }
}
Sneha Funde Staff answered 5 years ago
Resizable:

package com.xlfile;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;

public class Resizable
{
public static void main(String[] args)
{
System.setProperty("webdriver.chrome.driver", "C:\\Selenium Webdriver\\chromedriver.exe");

WebDriver driver=new ChromeDriver();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().window().maximize();

driver.get("http://jqueryui.com/slider/");

WebElement clickresize=driver.findElement(By.linkText("Resizable"));
clickresize.click();

WebElement frame1=driver.findElement(By.className("demo-frame"));
driver.switchTo().frame(frame1);
WebElement drag=driver.findElement(By.xpath("//*[@class='ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se']"));

Actions action=new Actions(driver);
action.clickAndHold(drag).moveByOffset(50, 50).build().perform();




}

}

Sneha Funde Staff answered 5 years ago
package com.xlfile;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;

public class Selectable
{
public static void main(String[] args)
{
System.setProperty("webdriver.chrome.driver", "C:\\Selenium Webdriver\\chromedriver.exe");

WebDriver driver=new ChromeDriver();

driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().window().maximize();

driver.get("http://jqueryui.com/slider/");

WebElement clickselect=driver.findElement(By.linkText("Selectable"));
clickselect.click();

//WebElement frame=driver.findElement(By.className("demo-frame"));
driver.switchTo().frame(0);
WebElement select1=driver.findElement(By.xpath("//*[@id=\"selectable\"]/li[5]"));
WebElement select2=driver.findElement(By.xpath("//*[@id=\"selectable\"]/li[3]"));
WebElement select3=driver.findElement(By.xpath("//*[@id=\"selectable\"]/li[2]"));

Actions act=new Actions(driver);
act.click(select1).build().perform();
act.click(select2).build().perform();
act.click(select3).build().perform();




}

}
Sneha Funde Staff answered 5 years ago
Sortable :

package com.xlfile;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;

public class Sortable
{
public static void main(String[] args)
{
System.setProperty("webdriver.chrome.driver", "C:\\Selenium Webdriver\\chromedriver.exe");
WebDriver driver=new ChromeDriver();

driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().window().maximize();

driver.get("http://jqueryui.com/slider/");
WebElement clicksort=driver.findElement(By.linkText("Sortable"));
clicksort.click();

driver.switchTo().frame(0);
WebElement sort1=driver.findElement(By.xpath("//*[@id=\"sortable\"]/li[1]"));
WebElement sort2=driver.findElement(By.xpath("//*[@id=\"sortable\"]/li[3]"));

Actions act=new Actions(driver);
act.dragAndDrop(sort1, sort2).build().perform();

}

}
Sneha Funde Staff answered 5 years ago
Accordion : 

package widgets;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;

public class Accordion
{
public static void main(String[] args) throws InterruptedException
{
System.setProperty("webdriver.chrome.driver", "C:\\Selenium Webdriver\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().window().maximize();

//get url
driver.get("http://jqueryui.com/slider/");

//click on accordion
WebElement accord=driver.findElement(By.linkText("Accordion"));
accord.click();

//Print title of page
WebElement title=driver.findElement(By.className("entry-title"));
String text=title.getText();
System.out.println(text);

//switch on inner frame
driver.switchTo().frame(0);


WebElement ClickSection2=driver.findElement(By.id("ui-id-3"));
Thread.sleep(500);
WebElement ClickSection3=driver.findElement(By.id("ui-id-5"));
Thread.sleep(500);
WebElement ClickSection4=driver.findElement(By.id("ui-id-7"));
Thread.sleep(500);
WebElement ClickSection1=driver.findElement(By.id("ui-id-1"));

//to perform click action
Actions act=new Actions(driver);
act.click(ClickSection2).build().perform();
act.click(ClickSection3).build().perform();
act.click(ClickSection4).build().perform();
act.click(ClickSection1).build().perform();





}

}