Skip to main content

Posts

Stray process cleanup in your test automation suite

Occasionally any large test automation suite leaves some stray browser and/or webdriver processes behind during test execution. They make our test suite slower and cause other issues, for example a stray process process may hold entire directory and prevent it from cleaning. Clean test environment is very important for test isolation and prevention of false positives. This is an example of process cleanup in Linux where we find the processes in question by their names and kill them. And here is another example where we do the same process cleanup in Windows Powershell.

Using SED and TR tools for text manipulations

SED and TR command line tools are very useful tools to perform various text manipulations in Linux. You can also find them on Mac OS X, however be aware that they could work a little differently from the same tools on Linux OS. Two very simple, but extremely useful one-liners (tested on Linux Ubuntu OS). The first one is wrapping your text with a div tag and "lazyload" class, also it wraps the text into HTML comment tags. The second one-liner is removing all newline characters from the text.

How to control CPU frequency on Linux Fedora 20

Sometimes you need to make CPU run faster or slower, depending on your needs. In Linux you can control this by using different CPU governors. The following steps were tested on Fedora 20, but most likely they would also work on later versions of Linux Fedora OS. sudo yum install kernel-tools Check the available CPU governors: sudo cpupower frequency-info --governors sudo cpupower frequency-set --governor [governor] More information about the governors here: http://docs.fedoraproject.org/en-US/Fedora/20/html/Power_Management_Guide/cpufreq_governors.html

Solution for com.jcraft.jsch.JSchException: reject HostKey problem on Ubuntu

Just a random investigation with a workaround. So trying to connect to SFTP server using jsch library, but getting a nasty com.jcraft.jsch.JSchException: reject HostKey exception. This host is already present in ~/.ssh/known_hosts file, so it should not be problem, but it is. It turns out this problem happens if SFTP server is running on Ubuntu and strictHostKey is set to true, but it doesn't happen on Linux Fedora. I suppose this is because host entries in the known_hosts file on Ubuntu are encrypted in a different way than in known_hosts on Fedora, so it cannot be recognized or decrypted by JSch library. Now all you need to do is manually add host entries to the file. Basically you just get the public key for the host where SFTP server is running using this command: ssh-keyscan -t rsa sftp_server_ip_address_or_hostname Then copy-paste the output to your local ~/.ssh/known_hosts file. That's all, it should work now. If it doesn't, try to empty known_hosts file complet...

Setting up SFTP server in Linux Ubuntu. Command line instructions

Simple step-by-step command line instructions on setting up SFTP server in Ubuntu 12.04, based on http://www.thegeekstuff.com/2012/03/chroot-sftp-setup/ article. 1. Add 'sftpusers' group: sudo groupadd sftpusers 2. Create a home directory for 'guestuser' user that will be added at the next step: sudo mkdir /var/guestuserhomedir As the result of the above command permissions for /var/guestuserhomedir should be 755 (owner: root, group: root). 3. Create 'guestuser' user, add it to the 'sftpusers' group and set a new password for this user: sudo useradd -g sftpusers -d /var/guestuserhomedir -s /usr/sbin/nologin guestuser sudo passwd guestuser 4. Create SFTP directories and set permissions (correct permissions are important): sudo mkdir /var/sftp_upload_dir sudo mkdir /var/sftp_upload_dir/guestuser sudo mkdir /var/sftp_upload_dir/guestuser/incoming sudo chown guestuser:sftpusers /var/sftp_upload_dir/guestuser/incoming sudo chmod 777 /var/sftp_u...

Disabling browser "Save As" dialog in Selenium WebDriver tests

How to disable Save As dialog in Selenium WebDriver tests? Solution for Firefox (add more MIME media types if necessary): FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.setPreference("browser.download.folderList",2); firefoxProfile.setPreference("browser.download.manager.showWhenStarting",false); firefoxProfile.setPreference("browser.download.dir", "/save/file/to/this/directory"); firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","text/html, application/xhtml+xml, application/xml, application/csv, text/plain, application/vnd.ms-excel, text/csv, text/comma-separated-values, application/octet-stream"); WebDriver driver = new FirefoxDriver(firefoxProfile); Solution for Google Chrome (this applies to all MIME media types): Map prefs = new Hashtable (); prefs.put("download.prompt_for_download", "false"); prefs.put("download.default...