Selenium – Automation of file upload with ngf-select

Usually when ngf-select is used for file upload, it is difficult to perform automation testing in selenium.

For Eg:

<input type=”text” ngf-select ng-model=”resume” />

This file upload will work when is it done manually. But it would fail on automation testing with selenium.

Solution
Since there is browse/file upload option, there should be a <input type=”file” />  in the DOM tree corresponding to aforementioned ngf-select element. If it is not visible, it means that it is hidden. Find that element and make it visible (through your selenium code) and then run the file upload operation on that element. It will work.

Advertisements

Some Linux commands which I search for freequently and forget to bookmark !!!

#1 Exclude a sub  directory while compressing a folder

While compressing a folder we often need to exclude some sub directories. I used this most of the times I work with python virtual environment.

tar -pczf flask-vehicle-app.tar.gz flask-works/ –exclude “flask-works/env”

Make sure that quotes are there for the folder name to be excluded…

ERROR in Node Sass does not yet support your current environment: Linux

We might come across this error at some point while dealing with node js and its related components.

ERROR in Node Sass does not yet support your current environment: Linux 64-bit with Unsupported runtime (57)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v3.13.1
@ ./lib/scss/bootstrap.scss 4:14-176

Try running the following command and which would fix the above issue.

npm rebuild node-sass

Debian : Setting environment variables for all users

An environment variable like JAVA_HOME can be set in different ways in  linux systems.

#1 . If we set environment variables in .bashrc file found in each users home directory, it will be accessible only for that user.

~/.bashrc   ——> specific to a particular user.

Setting environment variable for all users.
If the environment variable to be available for all users,

#2.   it can be set in /etc/environment

For instance let see how JAVA_HOME can be set,
Open this file in  vim or any editor of your choice, and add following line in it.
JAVA_HOME=”/usr/lib/jvm/java-8-openjdk-amd64″.
This sets JAVA_HOME for default open JDK. Please note that location is specified in quotes,

Then save the file and run the command, to have these these changes in effect immediately.
source /etc/environment
But this is not a recommended method.

#3. Setting via /etc/profile

vim /etc/profile (open the this file in vim )
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
Then save the file and run following command.
source /etc/profile

#4. Setting via /etc/profile.d
This can be viewed as an extension to the above step. Having all application specific environment file in /etc/profile makes the maintenance a hassle. As a solution to this, variables will be specified as a separate module inside the directory /etc/profile.d/. These modules are shell scripts and should end with .sh extension, otherwise system is not going to recognize it. You can read further on this from here.

I think this would be clear, with the following example.
In order to set JAVA_HOME bythis approach, first create a java_dev.sh file inside /etc/profile.d (The file should end with .sh extension ).

Then open this file using vim or any editor
vim /etc/profile.d/java_dev.sh
Then add following lines ( This JAVA_HOME location could be different for others)

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=${JAVA_HOME}/bin:${PATH}

Then save the file and run the following command.
source /etc/profile

You can also consider reading this

Linux – Exclude Certain Files and Folders while Copying

When we copy a certain folder to a remote machine using scp, we might want to exclude some sub folders or files. The following command worked for me in those kind of situations.

scp !(bin) root@target-machine:/opt/your-folder-name/  

In this case, it copies everything except the bin folder from the current working directory to /opt/your-folder-name/ folder in target-machine

Access denied issue with mysqlimport with remote machine

On importing a csv file into a table with same structure that placed on different machine, with mysql import using mysql root user , it is common that we may end up with some access denied error messages.

mysqlimport -h yourhostname –port 3306 -u root -pyourpassword –fields-terminated-by=’;’ –local csv_test tweet.csv

For instance the above stated query which worked in some machines, may raise

mysqlimport: Error: 1045 Access denied for user ‘root’@’ipaddress-of-remote-host’ (using password: YES)

The fix to this issue is as follows :

  1. First check the my.cnf file ( inside /etc/mysql folder ) and look for the line :

bind-address = 127.0.0.1

If it not commented, comments it out, as :

 #bind-address = 127.0.0.1

This tells system that, this mysql is accessible from different hosts as well.

2. Next we need to grant permission to the root user.

For that login to the mysql prompt using mysql -u root -p. Then execute the following query,

GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ IDENTIFIED BY ‘password’;

3. Now restart mysql using the command:

service mysql restart

VirtualBox – Copy Paste Not working (Debian)

Even though you have set bidirectional for the option Shared Clipboard in settings ( under General –>Advanced ) some times it will not work. The following steps fixed this issue for me.

In the guest OS do the following :

  1. update source.list file
  • enable the contrib repositories; e.g. for Debian 8, make sure your /etc/apt/sources.list contains something like
    deb http://ftp.debian.org/debian jessie main contrib

2.  Install guest addition software.


apt-get update
apt-get install virtualbox-guest-dkms