How to Resize an element using Selenium through Java? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Is Java “pass-by-reference” or “pass-by-value”?How do I efficiently iterate over each entry in a Java Map?What is the difference between public, protected, package-private and private in Java?How do I read / convert an InputStream into a String in Java?When to use LinkedList over ArrayList in Java?How do I generate random integers within a specific range in Java?Iterate through a HashMapHow do I determine whether an array contains a particular value in Java?How do I convert a String to an int in Java?Creating a memory leak with Java

Why are vacuum tubes still used in amateur radios?

How can I prevent/balance waiting and turtling as a response to cooldown mechanics

Putting class ranking in CV, but against dept guidelines

"klopfte jemand" or "jemand klopfte"?

Can you force honesty by using the Speak with Dead and Zone of Truth spells together?

Monty Hall Problem-Probability Paradox

Why datecode is SO IMPORTANT to chip manufacturers?

What is the difference between a "ranged attack" and a "ranged weapon attack"?

Getting out of while loop on console

Does silver oxide react with hydrogen sulfide?

retrieve food groups from food item list

Moving a wrapfig vertically to encroach partially on a subsection title

Understanding p-Values using an example

Why is it faster to reheat something than it is to cook it?

Flight departed from the gate 5 min before scheduled departure time. Refund options

Does any scripture mention that forms of God or Goddess are symbolic?

Nose gear failure in single prop aircraft: belly landing or nose-gear up landing?

Tannaka duality for semisimple groups

Is multiple magic items in one inherently imbalanced?

Is CEO the "profession" with the most psychopaths?

How does the math work when buying airline miles?

Sally's older brother

Is openssl rand command cryptographically secure?

Does the Mueller report show a conspiracy between Russia and the Trump Campaign?



How to Resize an element using Selenium through Java?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Is Java “pass-by-reference” or “pass-by-value”?How do I efficiently iterate over each entry in a Java Map?What is the difference between public, protected, package-private and private in Java?How do I read / convert an InputStream into a String in Java?When to use LinkedList over ArrayList in Java?How do I generate random integers within a specific range in Java?Iterate through a HashMapHow do I determine whether an array contains a particular value in Java?How do I convert a String to an int in Java?Creating a memory leak with Java



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















I am trying to automate the "realizable concept"(Drag and Drop) in Selenium through the link -http://jqueryui.com/resizable/.
I am getting the error:



invalid selector: Unable to locate an element with the xpath expression //div[contains(@class.'demo-frame')].


Could you please let me know if there is any other way of representing the XPATH?
Below is my code for the same. Thanks in advance.



public class ResizeExample 
WebDriver driver;

@Test
public void testToResizeElement()

driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.navigate().to("http://jqueryui.com/resizable/");
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.cssSelector(".demo-frame")));
WebElement resizeableElement = driver.findElement(By.cssSelector(".ui-resizable-handle.ui-resizable-se.ui-icon.ui-icon-gripsmall-diagonal-se"));
resize(resizeableElement, 50, 50);


public void resize(WebElement elementToResize, int xOffset, int yOffset)
try
if (elementToResize.isDisplayed())
Actions action = new Actions(driver);
action.clickAndHold(elementToResize).moveByOffset(xOffset, yOffset).release().build().perform();
else
System.out.println("Element was not displayed to drag");

catch (StaleElementReferenceException e)
System.out.println("Element with " + elementToResize + "is not attached to the page document " + e.getStackTrace());
catch (NoSuchElementException e)
System.out.println("Element " + elementToResize + " was not found in DOM " + e.getStackTrace());
catch (Exception e)
System.out.println("Unable to resize" + elementToResize + " - " + e.getStackTrace());













share|improve this question
























  • First thing xpath throwing error is due to the "@class**.**'demo-frame'. That "." should be "," and you don't have a div with that class, it's the iframe which had that class. Second: resizeableElement element is in a iframe so you have to switch to frame before checking if resizeableElement element exist and interact.

    – supputuri
    Mar 8 at 23:22

















2















I am trying to automate the "realizable concept"(Drag and Drop) in Selenium through the link -http://jqueryui.com/resizable/.
I am getting the error:



invalid selector: Unable to locate an element with the xpath expression //div[contains(@class.'demo-frame')].


Could you please let me know if there is any other way of representing the XPATH?
Below is my code for the same. Thanks in advance.



public class ResizeExample 
WebDriver driver;

@Test
public void testToResizeElement()

driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.navigate().to("http://jqueryui.com/resizable/");
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.cssSelector(".demo-frame")));
WebElement resizeableElement = driver.findElement(By.cssSelector(".ui-resizable-handle.ui-resizable-se.ui-icon.ui-icon-gripsmall-diagonal-se"));
resize(resizeableElement, 50, 50);


public void resize(WebElement elementToResize, int xOffset, int yOffset)
try
if (elementToResize.isDisplayed())
Actions action = new Actions(driver);
action.clickAndHold(elementToResize).moveByOffset(xOffset, yOffset).release().build().perform();
else
System.out.println("Element was not displayed to drag");

catch (StaleElementReferenceException e)
System.out.println("Element with " + elementToResize + "is not attached to the page document " + e.getStackTrace());
catch (NoSuchElementException e)
System.out.println("Element " + elementToResize + " was not found in DOM " + e.getStackTrace());
catch (Exception e)
System.out.println("Unable to resize" + elementToResize + " - " + e.getStackTrace());













share|improve this question
























  • First thing xpath throwing error is due to the "@class**.**'demo-frame'. That "." should be "," and you don't have a div with that class, it's the iframe which had that class. Second: resizeableElement element is in a iframe so you have to switch to frame before checking if resizeableElement element exist and interact.

    – supputuri
    Mar 8 at 23:22













2












2








2








I am trying to automate the "realizable concept"(Drag and Drop) in Selenium through the link -http://jqueryui.com/resizable/.
I am getting the error:



invalid selector: Unable to locate an element with the xpath expression //div[contains(@class.'demo-frame')].


Could you please let me know if there is any other way of representing the XPATH?
Below is my code for the same. Thanks in advance.



public class ResizeExample 
WebDriver driver;

@Test
public void testToResizeElement()

driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.navigate().to("http://jqueryui.com/resizable/");
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.cssSelector(".demo-frame")));
WebElement resizeableElement = driver.findElement(By.cssSelector(".ui-resizable-handle.ui-resizable-se.ui-icon.ui-icon-gripsmall-diagonal-se"));
resize(resizeableElement, 50, 50);


public void resize(WebElement elementToResize, int xOffset, int yOffset)
try
if (elementToResize.isDisplayed())
Actions action = new Actions(driver);
action.clickAndHold(elementToResize).moveByOffset(xOffset, yOffset).release().build().perform();
else
System.out.println("Element was not displayed to drag");

catch (StaleElementReferenceException e)
System.out.println("Element with " + elementToResize + "is not attached to the page document " + e.getStackTrace());
catch (NoSuchElementException e)
System.out.println("Element " + elementToResize + " was not found in DOM " + e.getStackTrace());
catch (Exception e)
System.out.println("Unable to resize" + elementToResize + " - " + e.getStackTrace());













share|improve this question
















I am trying to automate the "realizable concept"(Drag and Drop) in Selenium through the link -http://jqueryui.com/resizable/.
I am getting the error:



invalid selector: Unable to locate an element with the xpath expression //div[contains(@class.'demo-frame')].


Could you please let me know if there is any other way of representing the XPATH?
Below is my code for the same. Thanks in advance.



public class ResizeExample 
WebDriver driver;

@Test
public void testToResizeElement()

driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.navigate().to("http://jqueryui.com/resizable/");
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.cssSelector(".demo-frame")));
WebElement resizeableElement = driver.findElement(By.cssSelector(".ui-resizable-handle.ui-resizable-se.ui-icon.ui-icon-gripsmall-diagonal-se"));
resize(resizeableElement, 50, 50);


public void resize(WebElement elementToResize, int xOffset, int yOffset)
try
if (elementToResize.isDisplayed())
Actions action = new Actions(driver);
action.clickAndHold(elementToResize).moveByOffset(xOffset, yOffset).release().build().perform();
else
System.out.println("Element was not displayed to drag");

catch (StaleElementReferenceException e)
System.out.println("Element with " + elementToResize + "is not attached to the page document " + e.getStackTrace());
catch (NoSuchElementException e)
System.out.println("Element " + elementToResize + " was not found in DOM " + e.getStackTrace());
catch (Exception e)
System.out.println("Unable to resize" + elementToResize + " - " + e.getStackTrace());










java selenium selenium-webdriver webdriver action






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 9 at 9:01









DebanjanB

47.8k144892




47.8k144892










asked Mar 8 at 23:08









Chaitanya MaligiChaitanya Maligi

407




407












  • First thing xpath throwing error is due to the "@class**.**'demo-frame'. That "." should be "," and you don't have a div with that class, it's the iframe which had that class. Second: resizeableElement element is in a iframe so you have to switch to frame before checking if resizeableElement element exist and interact.

    – supputuri
    Mar 8 at 23:22

















  • First thing xpath throwing error is due to the "@class**.**'demo-frame'. That "." should be "," and you don't have a div with that class, it's the iframe which had that class. Second: resizeableElement element is in a iframe so you have to switch to frame before checking if resizeableElement element exist and interact.

    – supputuri
    Mar 8 at 23:22
















First thing xpath throwing error is due to the "@class**.**'demo-frame'. That "." should be "," and you don't have a div with that class, it's the iframe which had that class. Second: resizeableElement element is in a iframe so you have to switch to frame before checking if resizeableElement element exist and interact.

– supputuri
Mar 8 at 23:22





First thing xpath throwing error is due to the "@class**.**'demo-frame'. That "." should be "," and you don't have a div with that class, it's the iframe which had that class. Second: resizeableElement element is in a iframe so you have to switch to frame before checking if resizeableElement element exist and interact.

– supputuri
Mar 8 at 23:22












1 Answer
1






active

oldest

votes


















2














To automate the realizable concept(Drag and Drop) with in the webpage http://jqueryui.com/resizable/ through Selenium you can use the following solution:




  • Code Block:



    System.setProperty("webdriver.gecko.driver", "C:\Utility\BrowserDrivers\geckodriver.exe");
    WebDriver driver=new FirefoxDriver();
    driver.get("http://jqueryui.com/resizable/");
    driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@class='demo-frame']")));
    WebElement target = new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@class='ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se']")));
    //dragAndDropBy(WebElement source, int xOffset, int yOffset) //status: WORKS
    new Actions(driver).dragAndDropBy(target, 50, 50).build().perform();
    System.out.println("Resizing of element Completed");



  • Console Output:



    Resizing of element Completed


  • Browser Snapshot:


jQuery_resizable






share|improve this answer


















  • 1





    Thank you soo much for guiding and providing the right solution for my problem.

    – Chaitanya Maligi
    Mar 10 at 3:04











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55072243%2fhow-to-resize-an-element-using-selenium-through-java%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














To automate the realizable concept(Drag and Drop) with in the webpage http://jqueryui.com/resizable/ through Selenium you can use the following solution:




  • Code Block:



    System.setProperty("webdriver.gecko.driver", "C:\Utility\BrowserDrivers\geckodriver.exe");
    WebDriver driver=new FirefoxDriver();
    driver.get("http://jqueryui.com/resizable/");
    driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@class='demo-frame']")));
    WebElement target = new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@class='ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se']")));
    //dragAndDropBy(WebElement source, int xOffset, int yOffset) //status: WORKS
    new Actions(driver).dragAndDropBy(target, 50, 50).build().perform();
    System.out.println("Resizing of element Completed");



  • Console Output:



    Resizing of element Completed


  • Browser Snapshot:


jQuery_resizable






share|improve this answer


















  • 1





    Thank you soo much for guiding and providing the right solution for my problem.

    – Chaitanya Maligi
    Mar 10 at 3:04















2














To automate the realizable concept(Drag and Drop) with in the webpage http://jqueryui.com/resizable/ through Selenium you can use the following solution:




  • Code Block:



    System.setProperty("webdriver.gecko.driver", "C:\Utility\BrowserDrivers\geckodriver.exe");
    WebDriver driver=new FirefoxDriver();
    driver.get("http://jqueryui.com/resizable/");
    driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@class='demo-frame']")));
    WebElement target = new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@class='ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se']")));
    //dragAndDropBy(WebElement source, int xOffset, int yOffset) //status: WORKS
    new Actions(driver).dragAndDropBy(target, 50, 50).build().perform();
    System.out.println("Resizing of element Completed");



  • Console Output:



    Resizing of element Completed


  • Browser Snapshot:


jQuery_resizable






share|improve this answer


















  • 1





    Thank you soo much for guiding and providing the right solution for my problem.

    – Chaitanya Maligi
    Mar 10 at 3:04













2












2








2







To automate the realizable concept(Drag and Drop) with in the webpage http://jqueryui.com/resizable/ through Selenium you can use the following solution:




  • Code Block:



    System.setProperty("webdriver.gecko.driver", "C:\Utility\BrowserDrivers\geckodriver.exe");
    WebDriver driver=new FirefoxDriver();
    driver.get("http://jqueryui.com/resizable/");
    driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@class='demo-frame']")));
    WebElement target = new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@class='ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se']")));
    //dragAndDropBy(WebElement source, int xOffset, int yOffset) //status: WORKS
    new Actions(driver).dragAndDropBy(target, 50, 50).build().perform();
    System.out.println("Resizing of element Completed");



  • Console Output:



    Resizing of element Completed


  • Browser Snapshot:


jQuery_resizable






share|improve this answer













To automate the realizable concept(Drag and Drop) with in the webpage http://jqueryui.com/resizable/ through Selenium you can use the following solution:




  • Code Block:



    System.setProperty("webdriver.gecko.driver", "C:\Utility\BrowserDrivers\geckodriver.exe");
    WebDriver driver=new FirefoxDriver();
    driver.get("http://jqueryui.com/resizable/");
    driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@class='demo-frame']")));
    WebElement target = new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@class='ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se']")));
    //dragAndDropBy(WebElement source, int xOffset, int yOffset) //status: WORKS
    new Actions(driver).dragAndDropBy(target, 50, 50).build().perform();
    System.out.println("Resizing of element Completed");



  • Console Output:



    Resizing of element Completed


  • Browser Snapshot:


jQuery_resizable







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 9 at 9:02









DebanjanBDebanjanB

47.8k144892




47.8k144892







  • 1





    Thank you soo much for guiding and providing the right solution for my problem.

    – Chaitanya Maligi
    Mar 10 at 3:04












  • 1





    Thank you soo much for guiding and providing the right solution for my problem.

    – Chaitanya Maligi
    Mar 10 at 3:04







1




1





Thank you soo much for guiding and providing the right solution for my problem.

– Chaitanya Maligi
Mar 10 at 3:04





Thank you soo much for guiding and providing the right solution for my problem.

– Chaitanya Maligi
Mar 10 at 3:04



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55072243%2fhow-to-resize-an-element-using-selenium-through-java%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

Алба-Юлія

Захаров Федір Захарович