I am having trouble getting Selenium to work on Heroku in Java. I have seen tutorials online on how to get it to work in Javascript, but when I try to replicate it in Java, it does not work.
Here is what I'm doing currently:
options = new ChromeOptions();
options.setBinary(System.getenv("GOOGLE_CHROME_BIN"));
options.addArguments("--enable-javascript");
options.addArguments("--headless");
options.addArguments("--disable-gpu");
options.addArguments("--no-sandbox");
webDriver = new ChromeDriver(options);
I am also setting the environment variables inside the code and outside the code as well:
System.setProperty("GOOGLE_CHROME_BIN", "/app/.apt/usr/bin/google-chrome");
System.setProperty("CHROMEDRIVER_PATH", "/app/.chromedriver/bin/chromedriver");
System.setProperty("webdriver.chrome.driver", System.getenv("CHROMEDRIVER_PATH"));
Also I have added the two required buildpacks as well:
https://github.com/heroku/heroku-buildpack-chromedriver
https://github.com/heroku/heroku-buildpack-google-chrome
Here is the error: There was an unexpected error (type=Internal Server Error, status=500). no such element: Unable to locate element: {"method":"css selector","selector":"*[name='Address.SingleStreetAddress']"} (Session info: headless chrome=80.0.3987.122) For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html Build info: version: 'unknown', revision: 'unknown', time: 'unknown' System info: host: '802cc54f-7457-4dce-8dc8-b2a515ace0c1', ip: '172.16.123.202', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-1062-aws', java.version: '1.8.0_242-heroku' Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 80.0.3987.122, chrome: {chromedriverVersion: 80.0.3987.106 (f68069574609..., userDataDir: /tmp/.com.google.Chrome.xSbpT7}, goog:chromeOptions: {debuggerAddress: localhost:38506}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify} Session ID: abddccdd010de294bb0eaea9c7bae979 *** Element info: {Using=name, value=Address.SingleStreetAddress}
How would I get Selenium to work or what am I missing here in order to get it working on Heroku?