How to use scrollText method of org.cerberus.service.webdriver.impl.WebDriverService class

Best Cerberus-source code snippet using org.cerberus.service.webdriver.impl.WebDriverService.scrollText

Source:WebDriverService.java Github

copy

Full Screen

...144 message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_SCROLLTO);145 if (StringUtil.isNullOrEmpty(text)) {146 scrollElement(session, webElement);147 } else {148 scrollText(session, webElement);149 }150 }151152 return message;153154 } catch (NoSuchElementException exception) {155 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_SCROLL_NO_SUCH_ELEMENT);156 message.setDescription(message.getDescription().replace("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator()));157 LOG.debug(exception.toString());158 return message;159 } catch (Exception e) {160 LOG.error("An error occured during scroll to (element:" + identifier, e);161 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_GENERIC);162 message.setDescription(message.getDescription().replace("%DETAIL%", e.getMessage()));163 return message;164165 }166167 }168169 private void scrollText(Session session, WebElement element) {170 // Create instance of Javascript executor171 JavascriptExecutor je = (JavascriptExecutor) session.getDriver();172173 // now execute query which actually will scroll until that element is not appeared on page.174 je.executeScript("arguments[0].scrollIntoView(true);window.scrollBy(" + session.getCerberus_selenium_autoscroll_horizontal_offset() + "," + session.getCerberus_selenium_autoscroll_vertical_offset() + ");", element);175 }176177 private void scrollElement(Session session, WebElement element) {178 /**179 * WebElement element =180 * driver.findElement(By.id(identifier.getLocator())); Actions actions =181 * new Actions(driver); actions.moveToElement(element);182 * actions.perform();183 */ ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful