Recently I tried to use Selenium for Web UI auto testing, but when running driver.get()  function, I got following error



Following is full stacktrace

Starting ChromeDriver 2.29.461591 (62ebf098771772160f391d75e589dc567915b233) on port 20686
Only local connections are allowed.


at org.openqa.selenium.remote.ProtocolHandshake.streamW3CProtocolParameters(
at org.openqa.selenium.remote.ProtocolHandshake.createSession(
at org.openqa.selenium.remote.HttpCommandExecutor.execute(
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(
at org.openqa.selenium.remote.RemoteWebDriver.execute(
at org.openqa.selenium.remote.RemoteWebDriver.startSession(
at org.openqa.selenium.remote.RemoteWebDriver.<init>(
at org.openqa.selenium.remote.RemoteWebDriver.<init>(
at com.dfweb.service.impl.PaymentLogServiceImplTest.testCalcuateProfitWithDifferentAgentAndUserOfInventory(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
at org.junit.runners.model.FrameworkMethod.invokeExplosively(
at org.junit.internal.runners.statements.InvokeMethod.evaluate(
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(
at org.junit.runners.ParentRunner$
at org.junit.runners.ParentRunner$1.schedule(
at org.junit.runners.ParentRunner.runChildren(
at org.junit.runners.ParentRunner.access$000(
at org.junit.runners.ParentRunner$2.evaluate(
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(
at com.intellij.rt.execution.junit.JUnitStarter.main(
Suppressed: Incomplete document
at org.openqa.selenium.remote.ProtocolHandshake.createSession(
… 37 more



I look through the jar source code, and found there is class existed, but there is no toImmutableSet() method defined.

It’s because ImmutableSet.toImmutableSet() method is introduced in Guava version 21.0, while I’m using version 20.0.



My current pom.xml


Change version to 21.0 and run mvn install  will fix this issue.


.NET SQLite database is locked

I got following exception when I tried to modify the SQLite database using Entity Framework

System.Data.Entity.Core.EntityException: System.Data.Entity.Core.EntityException: An error occurred while starting a transaction on the provider connection. See the inner exception for details. —> System.Data.SQLite.SQLiteException: database is locked
database is locked.


The code causing the problem is following (the orderDao and productDao is wrapper of Entity Framework to manipulate SQLite database)


One common situation to cause this problem is that another application is accessing the same database.


In my situation it’s because that I opened the database with DB Browser for SQLite, deleted a database table and not applying the changes.

Clicking Write Changes (or Revert Changes or Close Database) and the error will be gone.

WPF PreviewKeyDown Fired Multiple Times

I want to implement such feature: In a barcode text box, when a “=” key (or “+” key) is pressed, the “=” (or “+”) character will not append to barcode textbox, and program will use textbox text as barcode to search product item.


To achieve this effect, we need use handle PreviewKeyDown event. Listening for KeyDown event is not working here, because when KeyDown event is fired, the new character is already appended to the textbox. (PreviewKeyDown is a tunneling event and KeyDown is a bubbling event)

But when I pressed “=” key, the PreviewKeyDown event is triggered multiple times.


By debugging I found only one event’s IsDown property is true, while other triggered events’ IsDown property is false and their IsUp property is true. To fix this solution we can check whether e.IsDown is true.

C# WPF Generate and Display QR Code

Download QrCode.Net

Download and install QrCode.Net from NuGet, there are two ways to install it.

Right click your project, select Manage NuGet Packages, in newly opened NuGet Package Manager tab, choose Browse tab and type QrCode.Net in Search text box, and install the QrCode.Net package by clicking the download icon at right side.


Run following command in Package Manager Console


Create Container Window

Create a window with name MainWindow and add an Image control named QrCodeImage into it.



Display QR Code in Window

In MainWindow.xaml.cs MainWindow constructor function, add following code (should be located after InitializeComponent() method)


Running the project you will see the QR Code is displayed in the MainWindow.



RavenDB NotSupportedException

When I run the code


I got following exception

RavenDB NotSupportedException

An exception of type ‘System.NotSupportedException’ occurred in Raven.Client.Lightweight.dll but was not handled in user code

Additional information: Could not understand expression: .Where(p => p.ProductSn.Contains(value(YSPOS.MainWindow+<>c__DisplayClass10_0).barCode))


It’s because there is no index for ProductSn attribute is created.



To fix this issue, we need create index fo ProductSn attribute.


Create a class extending AbstractIndexCreationTask class


Then execute this index creation task after DocumentStore initialization.


Ext JS 6 Modern Set Field Renderer in itemTpl

In Ext Js 6 Modern (or Sencha Touch), if Ext.grid.plugin.RowExpander plugin is enabled for Ext.grid.Grid, there will be a expander icon (plus icon) at left side of each row. Clicking the expander icon will expand the selected row, and more detail will be displayed. This detail page can be set by itemConfig.body.tpl option.


Like following code


And the tpl option is actually XTemplate, so the above code can be written as following form as well:


Note that here XTemplate cannot be replaced by Template class (using Template will display raw literal value as {…})



To use a renderer function for field in the template string, we need add a member function to the template

Then the template can be changed like this



Ext JS 6 Modern Set TabBar Scrollable

By default in Ext JS 6 Modern version (or Sencha Touch), the TabPanel’s TabBar is not scrollable. That means if opened tabs is too many that the TabBar will push the earlier tabs to left side, then they will become invisible anymore (because it’s not scrollable)

To make it scrollable, we need set tabBar.scrollable config to true when creating TabPanel

Then we can drag the TabBar to scroll it.


By default the scrollable is 'horizontal' , and of course you can set it to 'vertical' .




Ext JS 6 Duplicate Entity Name Error

When I reopened Account Profile tab after closing it, I got following error (shown in browser’s console)

Duplicate entity name “AccountProfileModelList”: AccountProfileModelList and AccountProfileModelList(…)


In this page, I defined a Model named AccountProfileModelList


When opening the Account Profile tab first time, the AccountProfileModelList will be defined. And when opening the tab second time, the AccountProfileModelList will be defined again. This is why the error appeared.

What’s interesting is that In Ext 5 above scenario won’t cause any error, but in Ext 6, a model cannot be defined twice anymore.


To fix this issue, we need use typeof(AccountProfileModelList) == 'undefined'  to check whether the model is already defined, if it’s defined the model creation code won’t be executed.

So the above code should be changed to


A more Ext way to detect whether a Ext class is already defined is using Ext.ClassManager.isCreated(className)

Above code can also be changed to


Ext JS 6 Invalid Component Id

In Ext 6, I got following error

ExtJs invalid component id “profile.ModifyUserBasicInfo”


Following is code producing the error


This error doesn’t appear in Ext 5, after upgrading to Ext 6, it appears now.


It is caused by the id property cannot contain “.” symbol, but the id property we used here is profile.ModifyUserBasicInfo

To fix this issue, we can replace all “.” to “-“.


Following link from describes the id property naming rule

The original quote

Note: Valid identifiers start with a letter or underscore and are followed by (optional) additional letters, underscores, digits or hyphens.




MySQL find all MyISAM tables

The information_schema table saves information about databases, tables, columns, indexes and triggers, etc.


To list all MyISAM tables, we can use following SQL


And to find MyISAM tables in database wordpress


Next filter them with a table prefix wp_