Categories
Programming

Xpath vs CSS Selectors

After researching and reviewing on whether to choose XPATH or CSS selector, the following are the points I came across.

 

Some points to CSS

Generally CSS is easy to use and readable over XPATH.

REF: http://www.seleniumhq.org/docs/appendix_locating_techniques.jsp#starting-to-use-css-instead-of-xpath

 

CSS is native to browsers and XPATH is not

REF: http://old.eurostarconferences.com/blog/2013/1/28/liveblogged!-automated-web-testing-traps-for-the-unwary-with-simon-stewart

CSS is preferred for testing as it is having more advantages over XPATH

REF: http://seleniumeasy.com/selenium-tutorials/css-selectors-tutorial-for-selenium-with-examples

 

Some points to XPATH

XPATH can travese up the document from a child element to parents.

REF: http://www.rapidprogramming.com/questions-answers/difference-between-css-and-xpath-css-vs-xpath-1388

 

Speed wise CSS and XPATH can be equal, or either one would be a bit speedier than other.

Therefore speed comparison can be ignored. However off the record, I have encountered that most mention that CSS is much faster than XPATH.

REF: http://elementalselenium.com/tips/33-xpath-vs-css-revisited

 

Conclusion

If we are down to select either CSS or XPATH reference, as I see we should compare the generated CSS and XPATH and select the better readable and short path locating string. Others comments are highly appropriated.

 

Additional Notes

Converting XPATH to CSS seletors: Following article layout on how to change XPATH element reference to CSS.

https://saucelabs.com/resources/selenium/css-selectors

 

Differences between CSS and XPATH

Ref: http://www.rapidprogramming.com/questions-answers/difference-between-css-and-xpath-css-vs-xpath-1388

 

A general guideline on how to select elements in a preferred order (where ID is the king)

https://blog.mozilla.org/webqa/2013/09/26/writing-reliable-locators-for-selenium-and-webdriver-tests/

https://thenewcircle.com/static/bookshelf/selenium_tutorial/locators.html

A video presentation on how why CSS is preferred on many occations and comprehensive presentation on CSS vs XPATH for Selenium.

https://www.youtube.com/watch?v=6vPu3TO6XZ4

 

Categories
Programming

NUC machines might be the next desktop killer

While it seems like to CPU processing power is coming to a limitation, Intel is focusing on small form factor machines.

Categories
Programming

Installing Unlimited Strength Jurisdiction Policy Files for your JRE

Today in work, I had to use AES encryption to basically encrypt and secret text and store it somewhere. This is with Ruby language so I ended up using ‘aes’ gem as it is build on top of OpenSSL and provides simple set of methods that can be used to encrypt and decrypt strings.

Following is the Git repository location which also has some guidelines on using the gem.

https://github.com/chicks/aes

Client wanted to use something similar to AES and we researched a bit and found it is easy to use for the situation. Basically in AES the key that is used for to encrypt is used to decrypt and get the original text.

secret-key

However during execution when encryption and decryption methods are called, the following Java encryption key size limitation policy issue was occurred:

Error occurred when decrypting encrypted string with key: Illegal key size: possibly you need to install Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files for your JRE (RuntimeError)

 

As it turns out that the Cipher class will generally not allow encryption with a key size of more than 128 bits. The apparent reason behind this is that some countries (although increasingly fewer) have restrictions on the permitted key strength of imported encryption software.

Ref: http://www.javamex.com/tutorials/cryptography/unrestricted_policy_files.shtml

 

Basically this is a forced restriction set by Java and can easily be fixed and there are two different solutions for this issue as mentioned in https://github.com/jruby/jruby/wiki/UnlimitedStrengthCrypto.

 

Method 1 – Install the “Unlimited Strength” policy files from Oracle

In this approach it is required to install unlimited strength cryptography in the JVM, corresponding to Jenkins machine running java version:

http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html

http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html

http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html

After downloading the relevant zip file, the JAR files located in that should be replaced with the same JAR files found in “<java-home>/lib/security” . A detailed installation instruction should be also included in the zip file.

 

Method 2 – Disable the crypto restriction programmatically

There’s also a gem called ‘unlimited-strength-crypto’ that programmatically disables this limitation.

Ref: https://rubygems.org/gems/unlimited-strength-crypto

However as specified in the document (https://github.com/jruby/jruby/wiki/UnlimitedStrengthCrypto), this approach may apply to Java 7+ only.

 

As I see method 2 appears to be better as the situation is handled by a gem and easy to use. However as mentioned above, it is necessary to update the Java 7 or upper version. 

Categories
Programming

Setting up xdebug with phpstorm

This guide provide a step by step details on how to set up phpstorm IDE to work with xdebug.

 

First download xdebug and copy it into the extension folder. Copy the full path the extension.

 

Add the following xdebug settings to php.ini file.

 

php.ini file

[XDebug]
zend_extension = “C:xamppphpextphp_xdebug-2.2.5-5.5-vc11.dll”
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_log=”c:tmpxdebugxdebug.log”
xdebug.show_exception_trace=0
xdebug.show_local_vars=9
xdebug.show_mem_delta=0
xdebug.trace_format=0
xdebug.profiler_enable = 1
xdebug.profiler_output_dir =”c:tmpxdebug”

 

 

Install easiest xdebug for Firefox and specify the remote IDE key for Firefox

Untitled picture

Then in the xdebug configuration apply following

Untitled picture

Put debug points and run the remote debug setting.

Untitled picture

 

enable the easiest debug and navigate the test page through the browser. Your debug should be hit, the request url is reading the debug file.

 

Notes:

To stop breaking at the first line Untick Run->break and first line…