node-google-oauth2 icon indicating copy to clipboard operation
node-google-oauth2 copied to clipboard

The blue button

Open robjens opened this issue 9 years ago • 3 comments

I am using clj-webdriver for my consent window. Using that, I can do

      (wait-until #(not (empty? (find-elements {:xpath "//button[@id='submit_approve_access' and not(@disabled)]"}))) (* 15000))

The xpath expression allows to define a condition which the css selectors do not offer, that is to select upon state of the element. Using a 15 second window in which the web page and consent screen must have loaded and disabled the blue button by script.

Lookup the JavaScript solution, as this is Clojure, but the functionality comes straight from webdriver/selenium and it demonstrates the how anyway, this might give a little closure ;) (last paragraph of your readme is about this)

robjens avatar Apr 19 '15 15:04 robjens

Oh and one extra gotcha was that, with webdriver/selenium firefox driver, it starts inside my /tmp and so it uses a anonymous user profile in firefox (temporary). As such, I needed to pass it the additional commands and data to fill in the gmail username/email and password first, before I could get to a consent window.

Next step: xvfb and true headless to work... ><

robjens avatar Apr 19 '15 15:04 robjens

Hi @robjens, thanks for the hint. Good to know that it works with selenium. Feel free to send a pull request in case you port your code to JS ;)

regular avatar Apr 19 '15 20:04 regular

I'll take a look sometime soon ^^

edit: it should be along these lines, no means or time to setup an environment and actually test it :P

driver.wait(function() {
    driver.findElement(By.id('submit_approve_access')).isEnabled().then(function(element) {
        element.click();
  });
}, 15000);

robjens avatar Apr 20 '15 07:04 robjens