Advertise

Saturday, February 2, 2013

WebDriver Alert and Prompts access

Alert alert = driver.switchTo().alert();

String alertText = alert.getText(); 

alert.accept(); // Accepting alert . Like clicking on OK button.

alert.dismiss(); // Dismiss alert . Like clicking on cancel button.

alert.sendKeys(Keys.BACK_SPACE); // Send keys. Example in my case i am sending backspace.

WebDriver Select- Select/Deselect Entries from drop down.


Select value form drop down:


WebElement option = driver.findElement(By.xpath("//path_to_drop_down"));

Select select  = new Select(options);

List<WebElement> allOptions= select.getOptions();
List<WebElement> allSelectedOptions= select.getAllSelectedOptions();

WebElement firstSelectedOption = select.getFirstSelectedOption();

select.selectByVisibleText("text to Select from drop down");

select.selectByIndex(0) //Select first index element

select.selectByIndex(1) //Select second index element

select.selectByValue("value to select")

select.deselectAll() // Clear all selected entries.

select.deselectByValue("deselect field value") // As name suggest deselect selected entry based on input.

select.deselectByIndex(0) // As name suggest deselect selected entry based on index.

select.deselectByIndex(1) // As name suggest deselect selected entry based on index.

select.deselectByVisibleText("deselect from drop down") // As name suggest deselect selected entry based on visible text.

Saturday, August 25, 2012

Screen Shot capture using selenium and storing with test method name

Taking Screen Shot using Selenium Webdriver.

Sample example to  help all in taking screen shot using selenium webdriver. It has been quit sometime i stopped posting update in my blog. 

So, Found this way to update this blog.Few more to come.






import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
import org.testng.ITestNGMethod;
import org.testng.ITestResult;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Listeners;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import org.testng.reporters.JUnitReportReporter;


/**
 *  Sample Test Case to show case how screen shot can be captured and stored with name of
 *  Test method. This would be useful when multiple test method are present in single java file
 */

@Listeners(SeleniumRunnerExample.class)
@Test(groups={"Sample1"})
public class SeleniumRunnerExample extends JUnitReportReporter
{
    WebDriver driver = null;
    ITestNGMethod method;


    @BeforeSuite
    public void driverInstantiationTest(){              
        ProfilesIni allProfiles = new ProfilesIni();
    
      // Creating custom profile of Firefox and referring to same.

        FirefoxProfile profile = allProfiles.getProfile("UIAutomation");

        //UIAutomation refer to profile created by user.This custom profile will be invoked by               
        //Webdriver for performing required activity on browser.

        profile.setAcceptUntrustedCertificates(false);

     
       // Setting whether to accept untrusted Certificate or Not.

        driver = new FirefoxDriver(profile);

       // New instance of Firefox driver with custom profile

        driver.get("https://www.example.com");
    
       // Opening https://www.example.com. Here https://www.example.com is just for example       
       // Purpose
      
    }  

  
    @Parameters({"url"})               //Parameter that is retrieved from "testng-suite.xml"
    @Test(description="Clear description of what this test method is doing should be updated here")
    public void exampleTest(String url){
    /**
     *   Sample implementation part should be written here.
     *
     * */
    }
  
    //takeScreenShotTest is having @ AfterMethod annotation. Since i want to take screen shot after      //each test case has been Run. So as to know where it terminated at last.



    @AfterMethod(description="Takes screen shot")
    public void takeScreenShotTest(ITestResult result) throws IOException{
        File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
        FileUtils.copyFile(scrFile, new File("D:\\\test-output\\screenshot"+result.getMethod().getMethodName()+".png"));
    }
  
    @AfterSuite
    public void closeBrowser(){
        driver.quit();
    }

}

Saturday, March 17, 2012

Which part of Selenium is appropriate for me?

  • Selenium IDE


Selenium IDE is an integrated development environment for Selenium scripts. It is implemented as a Firefox extension, and allows you to record, edit, and debug tests. Selenium IDE includes the entire Selenium Core, allowing you to easily and quickly record and play back tests in the actual environment that they will run.

Selenium IDE is not only recording tool: it is a complete IDE. You can choose to use its recording capability, or you may edit your scripts by hand. With autocomplete support and the ability to move commands around quickly, Selenium IDE is the ideal environment for creating Selenium tests no matter what style of tests you prefer.


Features:


  • Easy record and playback
  • Intelligent field selection will use IDs, names, or XPath as needed
  • Autocomplete for all common Selenium commands
  • Walk through tests
  • Debug and set breakpoints
  • Save tests as HTML, Ruby scripts, or any other format
  • Support for Selenium user-extensions.js file
  • Option to automatically assert the title of every page
  • NEW! Easy customization through plugins.


What is Selenium?

Selenium automates browsers. That's it. What you do with that power is entirely up to you. Primarily it is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can (and should!) also be automated as well.

Selenium has the support of some of the largest browser vendors who have taken (or are taking) steps to make Selenium a native part of their browser. It is also the core technology in countless other browser automation tools, APIs and frameworks.

Sunday, December 18, 2011

My Favourite vedios


Sometime its good to remember old technologies rather than leaving them behind.


As always said "Old is Gold". Old gave today gold. In Terms of technology.

My Favourite Vedio

Technology we forgot. Please check whether you remember this or not.

Sunday, February 27, 2011

HOW TO CONFIGURE VSFTPD WITH CHROOT ENABLE

HI Guys,


This session is for configuring chroot JAIL and locking the user to his home directory.

First step is to open the vsftpd configuration file.And uncomment below line .

#vim /etc/vsftpd/vsftpd.conf

##########################################################################
anonymouse_enable=no
local_enable=Yes
write_enable=yes
local_umask=022
dirmessage_enable=yes
xferlog_enable=yes
connect_from_port_20=yes
ascii_upload_enable=yes
ascii_download_enable=yes
chroot_local_user=YES
pam_service_name=vsftpd
userlist_enable=yes
tcp_wrapper=yes
##########################################################################


And now save the changes and restart the vsftpd service.

#/etc/init.d/vsftpd restart.

Now login to your ftp account and check .You should now will not be able to come out of your home directory.


Hope this session was interesting and should be help for the beginner in the Linux.

Regards
Ram kumar

Saturday, February 26, 2011

HOW TO CONFIGURE VSFTPD AND ENABLE FTP SERVER

HI GUYS.

This i am going to give an steps that need to be follow to configure VSFTPD BASED FTP SERVER WITHOUT CHROOT JAIL ENVIRONMENT.

Please install few vsftpd related packages in the Linux Box as mentioned below

#yum install vsftpd.

Now please configure vsftpd file as mentioned below .

#vim /etc/vsftpd/vsftpd.conf

now uncomment below line to make the ftp server operational.
##########################################################################
anonymouse_enable=no
local_enable=Yes
write_enable=yes
local_umask=022
dirmessage_enable=yes
xferlog_enable=yes
connect_from_port_20=yes
ascii_upload_enable=yes
ascii_download_enable=yes
pam_service_name=vsftpd
userlist_enable=yes
tcp_wrapper=yes
##########################################################################

Now after this restart vsftpd service to let the changes get reflected.

#/etc/init.d/vsftpd restart


Now access the ftp account from ftp tools or from browser.
And in case even after that you are not able to access your ftp home directory then please issue below command in the terminal to allow access to ftp home directory.

#setsebool -P ftp_home_dir 1


this should fix the issue and Hope this article give some good stuff for the beginner in Linux.

Regards
Ram kumar

Sunday, January 16, 2011

Monday, October 4, 2010

Xine Error the stream /tmp/ uses an unsupported codec:video codec:MPEG 1/2 (0x0) (null) start playback any

Hi Guys.


I was facing an issue while playing any video file in the xine .I used to get below message in a popup window and even if i am going to click any one of the option yes or no. It still exists and i was not able to play any media file in the xine.

So work around which i was able to get was mentioned below .

#yum install xine
#yum install xine-plugin
#yum install xine-lib
#yum install xine-lib-extras
#yum install xine xine-lib libdvdcss
#yum install xine-lib-extras-freeworld

Tuesday, May 25, 2010

Apache httpd-2.2.15 Compilation error make[3]: Leaving directory `/usr/local/src/httpd-2.2.15/os/unix' make[2]: *** [all-recursive] Error 1

HI All

I was getting Error while compiling the Apache in the Fedora 13.And Error is as below

Error=============================================================================

Error Log

unixd.c:54: error: expected declaration specifiers before ‘unixd_config_rec’
unixd.c:64: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
unixd.c:116: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
unixd.c:188: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
unixd.c:215: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
unixd.c:227: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
unixd.c:241: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
unixd.c:265: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
unixd.c:323: error: storage class specified for parameter ‘_hooks’
unixd.c:327: error: expected declaration specifiers before ‘AP_IMPLEMENT_HOOK_RUN_FIRST’
unixd.c:402: error: expected declaration specifiers or ‘...’ before ‘apr_proc_t’
unixd.c:405: error: expected declaration specifiers or ‘...’ before ‘apr_procattr_t’
unixd.c:406: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
unixd.c:418: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘proc_mutex_mech’
unixd.c:431: error: expected ‘)’ before ‘*’ token
unixd.c:484: error: expected ‘)’ before ‘*’ token
unixd.c:496: error: expected declaration specifiers or ‘...’ before ‘ap_listen_rec’
unixd.c:498: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/local/src/apache/include/http_config.h:975: error: old-style parameter declarations in prototyped function definition
/usr/local/src/apache/include/http_config.h:975: error: parameter name omitted
unixd.c:642: error: expected ‘{’ at end of input
make[3]: *** [unixd.lo] Error 1
make[3]: Leaving directory `/usr/local/src/httpd-2.2.15/os/unix'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/usr/local/src/httpd-2.2.15/os/unix'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/httpd-2.2.15/os'
make: *** [all-recursive] Error 1




Error=============================================================================


And the solution for the above issue is as mentioned Below

I have selected httpd-2.0.63 from the apache mirror and then i have compiled it and i was able to fix the issue.

Hope it should help some one who is facing similar issue.

Sunday, May 9, 2010

UBUNTU-10.04_64 Bit OS Flash Player Error

Hi All


I have installed Ubuntu 10.04 64bit Version in the my Laptop.But i was not able to play flash in my system , so work around for this issue is as mentioned below.

Solution

$sudo aptitude install ubuntu-restricted-extras

Then enter the password and then it will install all the software related to flash in your system.
Then you are done with your work.

Then Enjoy Flash and help spread Linux.

Regards
Ram kumar

Saturday, May 8, 2010

Wireless Config in Fedora 12_x86_64

Hi All

I am going to give you the steps that are needed to configure wireless Lan in the Fedora 12 64 Bit OS.
Tested on Dell Inspiron 1525
Steps are as follows

#yum install kmod-ndiswrapper
#mkdir /ndiswrapper_drivers
#cd /ndiswrapper_drivers

Now Get the drivers .inf and .sys files which you will get from the installation of wireless lan from the windows machine or click the wireless lan drivers that has been downloaded from the dell site. and Click Extract and find the .sys and inf files

Now get this file and put it in the Above directory

#cp xyydriver.inf /ndiswrapper_drivers/
#cp xyydriver.sys

Now issue below command
#ndiswrapper -i xyydriver.sys


Now you are done with drivers installation part now go to the NetworkManger and Configure the details Like SSID and DHCP ..

Once done it will show you the wireless Access Point .

Now for you reference i am attaching screen shot also

Hope this guide will help some one who need help in activating wireless lan from Linux Machine
And final thing help spread linux .




Regards
Ram kumar



Tuesday, May 4, 2010

OPENVPN-CONFIG-IPCOP-V1.4.20






Hello EveryBody

Below i am posting the steps that you need to follow in configuring the openvpn in IPCOP and And i have added zerina installer also in case if some one need them.

Zerina Installer:-http://rapidshare.com/files/380606118/ZERINA-0.9.5b-Installer.tar.gz.html

Thursday, February 18, 2010

Vino doesn't support telepathy






Hi All

I was able to fix the error which you are seeing on the image below by deploying vino rpm in the suse Linux.
And then i was able to share my desktop with my friends using Empathy Messenger

Thursday, November 5, 2009

Enter password for default keyring to unlock

Hi All

To Fix this error please move to your home directory and remove the file keyring that should fix the issue.For Example


#cd /home/ram/.gnome2/
# mv keyring keyring_old

Then try accessing the application that should work without any issue .

Sunday, November 1, 2009

Named Service failed

Error
[root@phpmyadmin ram]# /etc/init.d/named restart
Stopping named: [ OK ]
Starting named: [FAILED]

In the back end i got to know that i was facing the below mentioned error.

Apr 22 15:08:37 phpmyadmin named[10379]: loading configuration: file not found
Apr 22 15:08:37 phpmyadmin named[10379]: exiting (due to fatal error)
Apr 22 15:09:22 phpmyadmin named[10438]: starting BIND 9.3.4-P1 -u named -t /var/named/chroot
Apr 22 15:09:22 phpmyadmin named[10438]: found 2 CPUs, using 2 worker threads
Apr 22 15:09:22 phpmyadmin named[10438]: loading configuration from '/etc/named.conf'
Apr 22 15:09:22 phpmyadmin named[10438]: listening on IPv4 interface lo, 127.0.0.1#53
Apr 22 15:09:22 phpmyadmin named[10438]: listening on IPv4 interface eth0, 192.168.1.16#53
Apr 22 15:09:22 phpmyadmin named[10438]: /etc/named.conf:100: configuring key 'ddns_key': bad base64 encoding
Apr 22 15:09:22 phpmyadmin named[10438]: loading configuration: bad base64 encoding
Apr 22 15:09:22 phpmyadmin named[10438]: exiting (due to fatal error)


Solution:

To overcome above error

follow the below mentioned steps:-

# vim /var/named/chroot/etc/named.conf

then look for line 103

100 key ddns_key
101 {
102 algorithm hmac-md5;
103 secret "use /usr/sbin/dns-keygen to generate TSIG keys";
104 };
105 view "external"
106 {

then issue below command in the terminal to get a key
# /usr/sbin/dns-keygen
MYuDOCEckswLfQdVgMjwybFZcB69Jwjv9KMJw7AumSD54dJhdHre2dQYYYmz

Then replace above line(103) as mentioned in the below sample example:

100 key ddns_key
101 {
102 algorithm hmac-md5;
103 secret "MYuDOCEckswLfQdVgMjwybFZcB69Jwjv9KMJw7AumSD54dJhdHre2dQYYYmz";
104 };
105 view "external"
106 {

Then give a below mentioned command

[root@phpmyadmin ram]# /etc/init.d/named restart
Stopping named: [ OK ]
Starting named: [ OK ]
[root@phpmyadmin ram]#

That's it and Enjoys Guys

MANUAL TO RESTRICT A USER TO A SPECIFIC DATABASE

MANUAL TO RESTRICT A USER TO A SPECIFIC DATABASE
*************************************************************
1) First login to phpmyadmin
2) After login click on privileges
3) Then select add new user example: user : user1 Host : local host
passwd: ########
4) Then select go
5) exit
6) Please login with user1
7) you will see only default database
8) Then log off
9) Once again login to root account
10) Then click privileges
11) check the box user1 and click edit privileges
12) After that select add privileges on the following data base
13) Then from the drop down menu select the specific database
14) On selecting the data base pop the new window
15) Then check all , and give the password and select Go
16) Now exit the button .
Please see the below screen short