2

I have a Chrome extension that adds an entry to the browser's context menu, that allows a user to copy the top-level heading of a page to the clipboard.

Example:

Given the following HTML:

<h1>My Page</h1>

Right clicking on the page, selecting Plugin Name > Copy Title, will copy the string "My Page" to the clipboard. This should only work on a specified domain.

I'd like to write tests to ascertain that:

  • The context menu entry only appears on the specified domain
  • When on the specified domain, if I right click the page and select "Copy Title" that the correct string (i.e. the page's title) is copied to the clipboard.

How do I do that?

I'm not asking for the code, just for which tools are best suited to this job and a vague idea of the best order to do things.

Update: I have installed webdriver.io and managed to load the extension. Triggering a right click on the page shows the context menu and I can see my extension listed. I cannot however find any way to interact with the context menu:

.rightClick()
.keys(["Down arrow", "Down arrow", "Enter"]).then(function(val) {
  console.log(val);
});

The above snippet shows the context menu, but sending the "Down arrow" keys scrolls the page and doesn't cycle through the context menu options as I had hoped.

Does anyone know how to give the context menu focus?

Haibara Ai
  • 10,703
  • 2
  • 31
  • 47
James Hibbard
  • 16,490
  • 14
  • 62
  • 74
  • Would this help? http://stackoverflow.com/questions/11428026/select-an-option-from-the-right-click-menu-in-selenium-webdriver-java – Haibara Ai May 23 '16 at 10:49
  • Giving specific steps you'd like your extension to follow seems very much like you're asking for the code. You're also asking for: 1. which tools are best suited to the job, 2. a vague idea of the best order, 3. how to test that your extension is working properly, 4. how to give the context menu focus. I'd argue that only 3 & 4 are proper questions, but that you're muddied the waters quite a bit. – Teepeemm May 23 '16 at 14:26
  • @HaibaraAi: not really. That's Java. Thank you anyway. – James Hibbard May 23 '16 at 18:14
  • @Teepeemm: fair point. I wasn't sure whether to include the update, as it altered the focus of the question. – James Hibbard May 23 '16 at 18:16

0 Answers0