简体   繁体   中英

How to handle form in selenium which is coming while scrolling on webpage?

滚动时出现表单,我需要在该表单中发送搜索数据并单击提交。

You can use Actions class to scroll down to that item. sample code:

WebElement element = driver.findElement(By.id("my-id"));
Actions actions = new Actions(driver);
actions.moveToElement(element);
actions.perform();

you can make use of javascriptexecutor to scroll element into view

JavascriptExecutor js =(JavascriptExecutor)driver;
js.executeScript("arguments[0].scrollIntoView(true);",element);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM