0

I'm trying to test my company's Electron built browser https://github.com/maidsafe/safe_browser but am meeting a few challenges which I am looking for support / guidance with.

After a fair amount of research, it seems I essentially have two options - using Spectron as the test framework or Selenium with Chromedriver. I found a means to use a custom binary with Selenium by using Chrome Options and supplying the path to the browser executable and thought I was on to a winner with that but I hit a major issue - I could launch the browser but any interaction I tried (using the "typical" test automation approach I previously learn with Selenium Java) failed:

Eg WebElement secret = driver.findElement(By.cssSelector("#acc-secret"));

would not work - I got

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"#acc-secret"}

I also tried to interact with the element by Id and by xpath - none of which worked. I tried the different findElement methods with different on screen elements and could not get anything to work.

So, I gave up on that approach for the time being - if this had worked it would have been ideal as my automation experience lies with Selenium Java. It's OK though, I'm happy to learn new stuff, so I looked into Spectron.

However, I have found the documentation / blog posts around Spectron difficult to digest - I am a tester rather than a dev and, while I am technically competent, I found the level of assumed knowledge here higher than I currently possess. Plus, it all seems to be Javascript which I have little knowledge of. (This was why I was hoping to go be able to go the Selenium route which I am familiar with.)

What I want to do is to create a suite of tests independent of the browser's codebase where we (QA team) can build eg Page Object Models and associated test cases.

Any ideas / suggestions / guidance would be most gratefully received as I feel that I am not really getting far at the moment!

Calum
  • 1
  • 1

1 Answers1

0

You have received no such element error.

Check the following points.

  1. Make sure you are focusing the correct window.

  2. Make sure you have the correct locator.

  3. Do you have dev tools window open all the time.

For confirmation just get the page title and print it.

Bharath Kumar S
  • 1,332
  • 2
  • 8
  • 25
  • OK, I did `driver.getTitle()` and it returned `Background Process of SAFE Browser` which sounds like it explains why I can't interact with the page elements. – Calum Mar 06 '19 at 11:23
  • It should work but then try adding enough wait time before you start interacting with elements – Bharath Kumar S Mar 06 '19 at 11:51
  • I think I have the reason - spoke with the main dev working on the project and he tells me that when I launch the browser it actually creates two windows - a hidden background one and the main one. Seems Selenium is seeing the background one. Guess I need to do something like `driver.switchTo().window.` but it's not a method I am familiar with - further Googling required! – Calum Mar 06 '19 at 14:04
  • Use window handles in selenium – Bharath Kumar S Mar 06 '19 at 14:31
  • No, I haven't been able to get Selenium to talk to the page - I think the underlying issue lies with our app rather than Selenium but haven't had time to investigate further. – Calum Mar 25 '19 at 13:09