0

I'm trying to scroll inside form which is displayed in webpage. None of the scroll logic are working using Selenium. I tried to use Actions class as well as JavascriptExecutor, but scroll is not happening.

Steps:

  1. Navigate to https://www.ebay.com/b/Cell-Phones-Smartphones/9355/bn_320094
  2. Click on See All which should display a Form with left hand area scrollable

Code Written: Using Actions Class:-

WebElement element = waitUntilElementPresent(by);
        Actions actions = new Actions(DriverManager.getDriver());
        try{
            actions.moveToElement(element).click();
            actions = actions.sendKeys(Keys.PAGE_DOWN).click();
        }catch (Exception e){
            e.printStackTrace();
        }

Using JavascriptExecutor:-

((JavascriptExecutor) DriverManager.getDriver()).executeScript("window.scrollBy(0,250)");
Arun
  • 67
  • 5

1 Answers1

1

here is Python version:

driver.maximize_window()

driver.get("https://www.ebay.com/b/Cell-Phones-Smartphones/9355/bn_320094")

driver.find_element(
    By.CSS_SELECTOR, "div#mainContent>div:nth-of-type(1) >section:nth-of-type(1) div.b-carousel__seeall>button").click()

wait = WebDriverWait(driver, 30)
wait.until(EC.visibility_of_element_located(
    (By.CSS_SELECTOR, "div.x-overlay__body.dialog__body")))

driver.execute_script("arguments[0].scrollIntoView()", driver.find_element(
    By.CSS_SELECTOR, "div[data-aspecttitle='location']"))
Mahsum Akbas
  • 1,523
  • 3
  • 21
  • 38
  • I tried the above but its not getting scrolled. The tricky part here is Form with scroll on left panel and options displayed on right for the selected option which is actually not scrollable – Arun Feb 15 '23 at 14:29
  • I updated code, it worsk well. Also, in latest version of chromes no need scroll, you can click any part of not visible on View – Mahsum Akbas Feb 15 '23 at 15:19