How do I scroll down vertically in a specific div in a web page

前端 未结 4 2035
情书的邮戳
情书的邮戳 2021-01-22 18:48

I have searched all the forums but I didn\'t get a correct answer for my issue. My web page to test has a link hidden below, and I am trying to find it manually by searching for

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-22 19:24

    This is umendra tomar , I have found very simple solution for this, please use the below code for scroll a specific div in html using selenium .

    JavascriptExecutor js = (JavascriptExecutor)driver;
    js.executeScript("document.getElementById('scrollCustom').scrollTop= 450");
    
    scrollCustom =  this is the ID of your div which you want to scroll.
    document.getElementById =  this is use in javascript to locate a webelement. 
    

    Don't worry we can use this in java using javascriptExecutor

提交回复
热议问题