How to access elements when you get ElementNotInteractableException

My answer to this question on Quora:

How do I resolve the ElementNotInteractableException in Selenium WebDriver?

ElementNotInteractableException is caused when an element is found, but you can not interact with it. For instance, you may not be able to click or send keys.

There could be several reasons for this:

  1. The element is not visible / not displayed
  2. The element is off screen
  3. The element is behind another element
  4. Some other action needs performed (by the user) to enable it.

Strategies that may work to make it interactable (depending on the circumstance.)

  1. Wait until an element is visible / clickable
    WebDriverWait wait = new WebDriverWait(driver, timeout);
  2. Scroll until the element is within view
    Actions action = new Actions(driver);
  3. Use javascript to interact directly with the DOM
    JavascriptExecutor js = (JavascriptExecutor) driver;
                      element.value = 'whatever';")
  4. Perform whatever other action is necessary and possibly wait until after that.

Viewing or converting .flv video to .mp4

ffmpeg is a command line tool that can convert .flv videos to .mp4 (or another format).

ffmpeg -i video.flv -codec copy video.mp4

Ffmpeg is easy to script, but the number of command line options can be daunting.

Screen Shot 2018-01-09 at 4.42.52 PM.png

handbrake is a GUI application that can also convert .flv to .mp4.

Handbrake is actually a wrapper around ffmpeg that offers sensible defaults but still allows you access to many options.

Screen Shot 2018-01-09 at 4.38.41 PM.pngVLC is an app that can view .flv videos directly.  The VLC Player is free to use.

Screen Shot 2018-01-09 at 4.42.41 PM.png

Getting the spec name in Protractor for Sauce Labs

Say that you’re writing tests in Protractor, and say also that you’re running your tests on Sauce Labs.  You want to set your test name in Sauce Labs to match the spec.

You normally set the test name in Sauce Labs by sending “name” in the desired capabilities. = "your test name"

But in Protractor, the browser is created before starting the test.  The order of execution is:

1) Setup environment
2) Create a browser and setup globals 
3) Setup plugins 
4) Execute test cases 
5) Wait for postTest plugins to finish 
6) Teardown plugins 
7) Teardown

(in runner.ts)

The configuration file(s) are read and capabilities set in step 1.  Then the browser is created.  And only in step 4 are the spec files read.

There is an afterEach() hook that allows you to restart the browser for each test (if your test runner supports it, e.g. jasmine, mocha), and when using Sauce Labs (or Browserstack) to update the test status:

this.sauceServer_.updateJob(session.getId(), update, (err: Error) => {

(in sauce.ts)

We could use this updateJob method to also set the test name before each spec, but that would require changing the source code — it’s not available to the conf file or before each.

However, this same method can be called on the client side by using the Javascript executor.  So, in the beforeEach() method you can call:

browser.executeScript("sauce:job-name=whatever you want");

and it will change the test name in Sauce Labs. There is only one thing left to do to make this functional, get the spec name to set in the Javascript Executor.

This can be accomplished by getting the spec as a return value to the spec definition:

var spec = it('should set the spec name in Sauce Labs', function() { 
    browser.executeScript("sauce:job-name=" + spec.getFullName()); 

Now your tests in Sauce Labs reflect the text in your carefully worded spec description.

There’s one thing that can make this better.  Instead of adding this step to each spec, set it in your protractor conf.js file using the onPrepare() hook.

If you’re using mocha, no problem, but if you’re using Jasmine (the default Protractor test runner), well, this is a problem:

Let me just say here that often open source project maintainers pull the “because it is better” argument to mean “because I don’t know how”.  Ask Dostoyevsky about the mindset.

But, you could also use a custom reporter in Jasmine

onPrepare: function() {
        specStarted: function(result) { 
            browser.executeScript("sauce:job-name=" + result.fullName);
} }

If you add this to your protractor conf.js your tests will update with the spec fullname in Sauce Labs.

Here’s a working example:

Mapping Maps With Method References

I just learned about “method reference” notation in Java 8 thanks to Intellij IDEA code hints.

Consider the following code:

public class MapMap
   Map<String, String> map;
   public static void map(Object key, Object value)
      System.out.println(key + ":" + value);
   public void mapmap()
   { //...see implementations below }

I knew this:

/* loop */ 
for (Map.Entry entry: map.entrySet()) 
  map(entry.getKey(), entry.getValue()); 

could be replaced with this:

/* lambda expression */ 
map.forEach((key, value) -> map(key, value);

but I did not know about this:

/* method reference */ 

See the full gist here


See here for the official documentation on method references:


RESTful Web Services with Powershell

Working with a client recently and needed to check connectivity to a web service.  I wanted to make a few HTTP requests. Normally I’d fire up curl and paste a URL with basic auth credentials:


But… they were on Windows. No problem, fire up chocolately and install curl

choco install curl

Ah… this server is locked down and no way they’re going to fill out the paperwork (in triplicate) to install .  Someone said that PowerShell has curl installed.  But wait a minute…

Screen Shot 2017-08-18 at 3.21.40 PM

Someone has played a nasty trick on me.

I can’t use curl, but PowerShell has something not quite, but almost entirely unlike curl.  Let’s see what we can do with Invoke-WebRequest.

Ok, so you can call a URL with:

Invoke-WebRequest -Uri

It turns out that passing Basic Authentication credentials is trickier. But wait! stackoverflow comes to the rescue(-ish).

You have a -Credential flag, but all that does is open up a Windows dialog to enter them.  Not very automatable. (automatible? odd-tomato-bull?)

Basic authentication is really just an HTTP header:

GET /some/endpoint HTTP/1.1
Authorization: Basic SSBsb3ZlIEtlbHNleSBGb3g=

And the credentials are just a base64 encoded string containing text in the format


One last thing though, you need to escape the colon in your credentials.  Apparently backtick is the escape character in Powershell:

$credentials = "$username`:$password"

And you can pass an array of headers with Invoke-WebRequest.   (backtick also allows continuation on the next line)

Invoke-WebRequest `
-Uri `
-Headers @{ Authorization = "Basic $encodedCredentials" }

So now I’m getting somewhere.

The only step left is to figure out how to Base64Encode with PowerShell.  I’m not sure where I found it, but this will do the trick:

$encodedCredentials = `
[System.Convert]::ToBase64String( `

Remember folks, only you can prevent github from sharing your credentials.  Use an environment variable, and don’t put your password in powershell your script:

Here’s how you get an environment variable in Powershell

Get-ChildItem Env:USERNAME

Finally, here is my full script:

$username = $(Get-ChildItem Env:USERNAME).value
$password = $(Get-ChildItem Env:PASSWORD).value

$credentials = "$username`:$password"
$encodedCredentials = `
[System.Convert]::ToBase64String( `

Invoke-WebRequest `
-Uri `
-Headers @{ Authorization = "Basic $encodedCredentials" }

But wait, there’s more!

Now that I’ve got my response I can actually use Powershell to parse the JSON response and access it using ConvertFrom-Json.:

Given the following JSON

[{ "contact": { "name": "Aaron Evans", "website": { "url": "" }, "blog": { "url": "" } }}]

I could parse it like this:

$response = $(Invoke-WebRequest -Uri "$endpoint" -Headers $headers)
$contacts = $(ConvertFrom-Json -InputObject $response.Content)

Invoke-WebRequest -Uri  $contacts[0]

Please don’t flood my blog with hits.  I haven’t monetized it yet.

See the whole thing with this gist:




Disable Integrated Windows Authentication (IWA) for Selenium

Here’s the problem:

You have a site that you’d like to write automated tests for.  But when you attempt to login with Internet Explorer, it has a Windows Authentication dialog popup. Because this is a native UI element, Selenium can’t touch it.

If you have control of the machine (and the Windows ADFS domain controller), you can add the user and the popup will go away.  But if you don’t have control — like if you’re running your tests on a virtual machine in the cloud with Sauce Labs — you need to find a way to get around it.

I recently ran into this problem.  It only affected Internet Explorer.  Chrome and Firefox were directed to a web login form — which could be automated with Selenium.  The options were to either A) figure out how to authenticate with Windows, or B) bypass Windows Authentication so it doesn’t have the native popup, and it doesn’t block tests.

I think I’ve found a solution.

You can disable Integrated Windows Authentication under “Internet Options” for Internet Explorer.  Under the “Advanced” tab, scroll down to “Security” and uncheck “Enable Integrated Windows Authentication”.  That should do it.



But there was still the task of automating this step.  I thought of trying a macro tool like AutoIt, but that just didn’t feel right.  Plus, it can be tricky to actually use AutoIt.  I don’t want to learn their language, and the recorder has been removed from AutoIt.

Click here to see how to get an older version of AutoIt that still has a working recorder:

I knew there must be some way to do this without resorting to UI automation.  So, after a little poking around, I found this old blog post:

Thanks Tom!

A little more searching taught me all I need to know about using Powershell to edit registry keys:

Combining the two gave me this nice little script:

Set-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -name EnableNegotiate -value 0
Get-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"


And now I can execute that on a remote computer before running my Selenium automation!

Sauce Labs has the following in their wiki about using AutoIt as a pre-run executable:

And some general information about specifying a pre-run executable in your Desired Capabilities.

Thanks Sauce Labs!

And thanks to the team that set up this challenge — you know who you are ;)