At work we are passing the --remote-debugging-port=9555 parameter to a CEF based desktop app and launching it using Runtime.getRuntime.exec("path to app"). Then, using selenium, we open an instance of chrome and open the link http://localhost:9555 in it. This displays the entire html code of the desktop app in that browser instance. Then we perform interactions like button clicks and data entry on the chrome browser using selenium. Any interaction performed on the browser is reflected on the app as well.
On many screens of the desktop app, the html visible on chrome browser to the user is different from the html visible to selenium. We confirmed this by running driver.getPageSource() and observing completely different css and html. Due to this, buttons visible to the user on the screen are not visible to selenium. Hence selenium cannot click on the buttons on those screens. Is there way to solve this problem and get selenium to interact with those buttons?

  • getPageSource returns the original delivered HTML. AJAX and JavaScript in the page can and will alter the state of the page during loading, page actions, and the like. These changes are not seen in pageSource. However, this should not be a problem for Selenium, as Selenium itself deals with the page structure as currently exists, and doesn't depend on pageSource. So I suggest your problem is something else, such as broken locators. Jun 6, 2020 at 1:29

2 Answers 2


If you query the page source using selenium you'll actually get the source and not the DOM, so anything you do dynamically to the source code via JS will not be displayed in the output. Seleniums interactions though do actually access the DOM so using the returned page source as a metric for what is "visible" to selenium is problematic at least. If you'd provide some more information on what you're actually trying to do I'd like to provide some more constructive advice.


I know it's a old thread. just want to understand how you identified the element using selenium "Then we perform interactions like button clicks and data entry on the chrome browser using selenium." When i use the locator identified, it's says element not found. how did you connect back to your application browser.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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