+ Reply to Thread
Results 1 to 14 of 14

Move webelement outer screen

  1. #1
    Registered User
    Join Date
    07-24-2023
    Location
    Oirschot, Netherlands
    MS-Off Ver
    2016
    Posts
    11

    Move webelement outer screen

    Hello
    I use VBA with Seleniumbasic on my Windows 10 system.
    I log in to a website where I have an account and surf to a page where my personal data is stored, which can have many web elements.
    To sort that data, I created a piece of code that puts the web elements in the correct order. This code works correctly but only if the element needs to be moved within the screen. For example, if a web element has to move 30 places, it doesn't work because this element is off screen. The web page scrolls down but does not move the web element.
    As long as X1 < 14 then it works, element 15 is at the bottom, just out of view
    Can anyone help me with this?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,950

    Re: Move webelement outer screen

    You should be able to first set element by xpath.
    Then use...
    Please Login or Register  to view this content.
    to get the element into view.
    For sanity check, you can then check that your element is visible by using... WebDriverWait.
    Ex; Wait until element is visible. Or 10 sec timeout.
    Please Login or Register  to view this content.
    Edit: In general you should maximize window before driver.execute_script to get the element into view using driver.maximize_window()
    Last edited by CK76; 05-27-2024 at 01:16 PM.
    "Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something."
    ― Robert A. Heinlein

  3. #3
    Registered User
    Join Date
    07-24-2023
    Location
    Oirschot, Netherlands
    MS-Off Ver
    2016
    Posts
    11

    Re: Move webelement outer screen

    Thank you CK76 for your help, unfortunately, that did not provide the solution.
    As long as the movement is within the screen (X1 < 15), everything goes well. If it falls outside the screen, the screen will scroll to the correct position but the movement will not take place.
    This is my full code, Would you mind taking a look at what's going wrong?


    Please Login or Register  to view this content.

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,950

    Re: Move webelement outer screen

    In that case, try using offset. Instead of element drag and drop, use offset drag and drop. First you should find coordinate of the destination element.

    Ex: x is horizontal offset, y is vertical offset.
    Please Login or Register  to view this content.
    If above still does not work. Instead of using built-in drag and drop... you will have to use action builder / action chains to build scroll operation (move_to) along with click and hold etc.

  5. #5
    Registered User
    Join Date
    07-24-2023
    Location
    Oirschot, Netherlands
    MS-Off Ver
    2016
    Posts
    11

    Re: Move webelement outer screen

    Thank you again for your response.
    I have already tested with offset in recent weeks, but without results. But I will try this again.
    Then I will use the 'build' option, although that is a different programming technique than VBA with SeleniumBasic

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,950

    Re: Move webelement outer screen

    You should have ActionChains, assuming you are using GCuser99's SeleniumVBA

  7. #7
    Registered User
    Join Date
    07-24-2023
    Location
    Oirschot, Netherlands
    MS-Off Ver
    2016
    Posts
    11

    Re: Move webelement outer screen

    Thank you, I will Google to learn this.
    It may take a while, but when it works I will post the code here so that others can benefit from it as well.

  8. #8
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,950

    Re: Move webelement outer screen

    Good luck. Unfortunately I'm not aware of any site that does drag and drop with scroll. So can't write a code to test.
    If you have public site that has this, I could help a bit better.

  9. #9
    Registered User
    Join Date
    07-24-2023
    Location
    Oirschot, Netherlands
    MS-Off Ver
    2016
    Posts
    11

    Re: Move webelement outer screen

    Good morning CK76, thank you again for your help, it is much appreciated.
    I don't just ask for help, I only do that after trying for weeks without results. The site where I have an account offers a 14-day trial period to test, after which a subscription is required. If you agree, I can create an account with a playlist in it. I will then put 20 training videos in that playlist and I will send you the code as I have it now, in which the URLs are visible and the login name and password of the test account are included, by PM. Put that code in a normal module. The results achieved will be posted publicly on this forum. Let me know what you think of this proposal. Perhaps it is possible to send you a small Excel workbook with just that code.

    After your previous message, I have already been busy and installed SeleniumWrapper on my system and added this Library Reference to the workbook.

  10. #10
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,950

    Re: Move webelement outer screen

    Sure. I won't have time to look at it much this week. But perhaps next week.

  11. #11
    Registered User
    Join Date
    07-24-2023
    Location
    Oirschot, Netherlands
    MS-Off Ver
    2016
    Posts
    11

    Re: Move webelement outer screen

    Thank you, I will send the code with the login details next Tuesday or Wednesday. Have a nice weekend.

  12. #12
    Registered User
    Join Date
    07-24-2023
    Location
    Oirschot, Netherlands
    MS-Off Ver
    2016
    Posts
    11

    Re: Move webelement outer screen

    I finally got it working with VBA and SeliniumBasic.

    Please Login or Register  to view this content.

  13. #13
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,950

    Re: Move webelement outer screen

    To add to OP. What was causing issue here, is that site did not allow scroll operation while ClickAndHold() is taking place. Thus limiting drag and drop to on screen.

    Op found module that drops item in centre of screen to do it in multiple steps.

  14. #14
    Registered User
    Join Date
    07-24-2023
    Location
    Oirschot, Netherlands
    MS-Off Ver
    2016
    Posts
    11

    Re: Move webelement outer screen

    Hello CK76
    At the moment I am working on putting this code in a do...loop. Multiple videos may need to be sorted. These movements will mainly be moved downwards, but upwards should also be possible. Not simple because after moving element(2) to position 8, the element(3) is then in the second position. But I know how I'm going to do this and it already works pretty well.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Buttons to move in relation to userform on screen
    By JamesT1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-30-2013, 05:10 AM
  2. Using VBA to move screen selection
    By MDubbelboer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-23-2006, 05:50 PM
  3. Select a Cell - Move Row to the Top of the screen
    By CRayF in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-26-2005, 06:05 AM
  4. Move the position of spreadsheet on the screen
    By Souris in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-23-2005, 01:05 AM
  5. Replies: 6
    Last Post: 05-29-2005, 12:35 AM
  6. [SOLVED] arrow keys move screen but not curser
    By JReiss in forum Excel General
    Replies: 1
    Last Post: 04-21-2005, 11:06 AM
  7. Replies: 3
    Last Post: 02-25-2005, 03:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1