selenium webdriver javascript queries

I have been recently using selenium webdriver (nodejs module) in combination with mocha, for writing automation tests and these are some of the issues that I faced

Scrolling

driver.findElement()

returns false since it is not able to locate the element since it is not visible in the current window but somewhere below. Reading some blogs, I thought scrolling would solve the issue.But,I cant find an API in selenium that helps me scroll up,down,left,right in the browser. I tried using the

scrollBy(xDelta,yDelta)

method of javscript inside the it() clause, but it did not work either

Reading the text of an element where the text gets updated dynamically from back end.

The text is not present in the text attribute of the DOM element. I have the element's xpath, So that is my only means of accessing the element.

I have two requirements

A.) I need to read and get the value of some elements in the html page and store it

B.) I need to read the element and assert it against some text

can you please tell me the webdriver nodejs API methods for performing the same.

Waiting for a particular text

The text of the element that I am trying to read changes over time in response to various events. How do I programatically wait for a particular text using selenium webdriver's javascript API

I am new to selenium and though I found many discussions for the above questions, but they were all for other platforms of selenium such as java,etc; there is very less documentation for the nodejs platform of the selenium API . So please help me with the same

Much Thanks in advance

You don't need to scroll to element using selenium webdriver. If you want to perform some operation on element which is placed somewhere at the bottom of the page, then selenium will scroll page and click on element (or perform another action);

Selenium-webdriver uses promises (see this documentation for more info to return values of element/it's attributes so if you want to get some element/or value of it's attribute you need to do next:

driver.findElement(webdriver.By.css("some selector")).then(function(elem){
    //e.g. return text in element
      return elem.getText().then(function(text){
            expect(text).toBe("your text");
      });
})

You don't need to use any particular method in selenium to wait until text is changed, just create loop which will look for value in element for some amount of time.