I've been using selenium to autofill credit card information for certain websites. I use ChromeDriver and it had been working fine, but yesterday it seems like the website I had been using blocked this feature (At least I think). Here is the code I've been using. As you'll see in the code, I also tested it with FireFox and it worked just fine, so I thought it could be a ChromeDriver issue, but I've tried different versions and they all seem to have this problem on this specific website. I tried using it on google and searching something and it worked just fine with the ChromeDriver.

    public static void main(String[] args) throws Exception {

    System.setProperty("webdriver.chrome.driver", "C:\\Users\\Name\\Desktop\\WebStuff\\chromedriver.exe");

    ChromeOptions options = new ChromeOptions();
    options.setHeadless(false);

    //FirefoxOptions options = new FirefoxOptions();
    //options.setHeadless(false);

    WebDriver driver = new ChromeDriver(options);

    driver.get("http://www.supremenewyork.com/shop/accessories/z1fwxyqis");

    WebElement cart = driver.findElement(By.cssSelector("input.button"));

    cart.submit();

    Thread.sleep(1000);

    driver.get("http://www.supremenewyork.com/checkout");

    Thread.sleep(500);

    System.out.println("About to hit billing");

    WebElement name = driver.findElement(By.id("order_billing_name"));

    name.sendKeys("testing name");


}

Here is also the error I get in console

Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node'.
  (Session info: chrome=65.0.3325.181)
  (Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Windows NT 10.0.16299 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:08.638Z'
System info: host: 'DESKTOP-DOHH590', ip: '192.168.1.132', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_161'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.37.544315 (730aa6a5fdba15..., userDataDir: C:\Users\Shayan\AppData\Loc...}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 65.0.3325.181, webStorageEnabled: true}
Session ID: 26e9dd507ff523a3444484b7fedb8793
*** Element info: {Using=id, value=order_billing_name}
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
    at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
    at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
    at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:319)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:365)
    at org.openqa.selenium.By$ById.findElement(By.java:218)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:311)
    at me.iran.testing.Main.main(Main.java:39)
  • I did look online and everyone that had similar problems (About a year ago) was due to the ChromeDriver bug, but I'm using the most recent one and no one else is having an issue with it. – Irantwomiles Apr 12 at 21:12
  • This doesn't seem to be an issue with blocking sendKeys. I have tried to run your code in phantomjs and it works fine. I only changed the page source to supremenewyork.com/shop/tops-sweaters/v2reiq8w5 since the one provided by you is not accessible. – Alexey R. Apr 13 at 8:18
  • The URL i posted seems to work for me, unless you're talking about something else. What do you suggest I should use? My friend is also having the same issue. – Irantwomiles Apr 13 at 20:42

I can open the DevTools console and execute:

document.querySelector("#order_billing_name").value = "Kirby"

Which does the same thing (without using Java to actually send the keystrokes).

So, without seeing the actual error you get, here are a few guesses:

  1. I am going to assume that 500ms is not a good amount of time to wait for the cart to load.
  2. The input is data-bound so the manual act of entering text also triggers certain events ("onchange", "blur", "focus", etc).
  3. You need to update Chrome and the Chrome WebDriver.
  • Sorry @kirbycope, let me upload the error to post. – Irantwomiles Apr 12 at 21:34
  • Also to answer your other questions. 1) I tried doing it with a higher/lower waiting time in between. 2) I understand what you mean, but not sure what I should do. 3) I have the latest driver and browser. – Irantwomiles Apr 12 at 21:40

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.