Using Angular JS (protractor) with selenium in Python

I am trying to select textarea wrapped in angular 1 using selenium , but it cannot be seen in the DOM. There is a module called Pytractor . I tried to solve it, but I cannot use it correctly.

Can anyone help me with this?

+4
source share
2 answers

You can also use regular selenium bindings to test AngularJS applications. You will need to use Explicit Waits to wait for the elements to appear, disappear, the header / url to change, etc. - for any actions that would allow you to continue with checking the page.

Example (waiting for an element to appear textarea):

from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

wait = WebDriverWait(driver, 10)
wait.until(EC.visibility_of_element_located((By.TAG_NAME, "myaccount")))

There is one important thing that provides pytractor(how protractor) - it knows when it is AngularJSinstalled and ready - the models are updated, there are no outstanding asynchronous requests, etc. This does not mean that you should use it to test applications AngularJS, but it gives you an advantage.

, pytractor , . . , , , selenium python .

, pytractor .

+9

. , , Angular .

def wait_for_angular(self, selenium_driver):
    selenium_driver.set_script_timeout(10)
    selenium_driver.execute_async_script("""
        callback = arguments[arguments.length - 1];
        angular.element('html').injector().get('$browser').notifyWhenNoOutstandingRequests(callback);""")

'html' - 'ng-app'.

Angular 1 /lib/clientsidescripts.js#L51. Angular 2

+1

All Articles