My Thoughts: About Me

About Me

Hey ,

Firstly thanks thanks thanks for taking your valuable time to read about me and ofcourse my blog :)

This is Vamshi Kurra.This blog is about my thoughts on life and my little little little knowledge on testing , test automation tools & other technical topics.

Personal :

Colors   : Black and Blue
Hobbies : Blogging and Reading Books

Have a great great day .. !! :)

36 comments:

  1. Very good blog for automation...please some more information about webdriver...

    Thanks,
    Sravan

    ReplyDelete
    Replies
    1. Thanks Vamshi.Your blog is really packed with useful information.Thanks for sharing such great information with us all.

      -Vishal Aggarwal
      http://testocean.blogspot.in

      Delete
    2. Thanks Vishal..!!

      Between your blog is awesome :)

      Delete
  2. Hey guys i am stuck with the problem here in reading the program from excel file and putting the values in web page. I have done the 2 ways first is through jexcel api and the program is below
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.Locale;
    import jxl.Cell;
    import jxl.Sheet;
    import jxl.Workbook;
    import jxl.WorkbookSettings;
    import jxl.read.biff.BiffException;
    import jxl.DateCell;

    public class operationclass {

    public void init(String filePath) {
    FileInputStream fs = null;
    try {
    fs = new FileInputStream(new File(filePath));
    contentReading(fs);
    } catch (IOException e) {
    e.printStackTrace();
    } catch (Exception e) {
    e.printStackTrace();
    }finally {
    try {
    fs.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }

    //Returns the Headings used inside the excel sheet
    public void getHeadingFromXlsFile(Sheet sheet) {
    int columnCount = sheet.getColumns();
    for (int i = 0; i < columnCount; i++) {
    System.out.println(sheet.getCell(i, 0).getContents());
    }
    }

    public void contentReading(InputStream fileInputStream) {
    WorkbookSettings ws = null;
    Workbook workbook = null;
    Sheet s = null;
    Cell rowData[] = null;
    int rowCount = '0';
    int columnCount = '0';
    DateCell dc = null;
    int totalSheet = 0;

    try {
    ws = new WorkbookSettings();
    ws.setLocale(new Locale("en", "EN"));
    workbook = Workbook.getWorkbook(fileInputStream, ws);

    totalSheet = workbook.getNumberOfSheets();
    if(totalSheet > 0) {
    System.out.println("Total Sheet Found:" + totalSheet);
    for(int j=0;j(CompoundFile.java:116)
    at jxl.read.biff.File.(File.java:127)
    at jxl.Workbook.getWorkbook(Workbook.java:268)
    at operationclass.contentReading(operationclass.java:54)
    at operationclass.init(operationclass.java:19)
    at operationclass.main(operationclass.java:108). i dont know how to get rid of this error.can u guys help me please?

    ReplyDelete
  3. You can use regular FileReader class of java to read excel file.

    Here is the sample code .

    import java.io.IOException;
    import java.io.BufferedReader;
    import java.io.FileReader;

    public class Excel{

    public static void main(String [] args) throws IOException{

    String sCurrentLine;

    BufferedReader CSVFile = new BufferedReader(new FileReader("FILEPATH"));
    String rows = CSVFile.readLine();

    while ((sCurrentLine = CSVFile.readLine()) != null) {
    System.out.println(sCurrentLine);
    }

    }

    Does this help ?

    ReplyDelete
  4. Oh boss you are trying too much just use the below
    Workbook wb=Workbook.getWorkbook(new File(uri));
    Sheet s=wb.getSheet(sheet_name);

    for(i=0;i<s.getRows();i++)
    {
    for(j=0;j<s.getColumns();j++)
    syso(s.getCell(i, j).getContents());

    ReplyDelete
  5. Nice blog vamsi i will share u r few posts in my blog.....

    ReplyDelete
  6. hey sanjay i have something similar in ruby u can try this
    hope u will get some idea


    #-------------------------------------------------1. Login and Logout Test Case (Using values from xls file)---------------------------------------------


    require 'selenium-webdriver'
    require 'test/unit'
    require 'roo'
    require 'rubygems'

    class TC_Login < Test::Unit::TestCase #------------ define a class----------------

    @@driver = Selenium::WebDriver.for :firefox #-------- Define driver element---------
    @@driver.navigate.to "URL" #---- call url----
    @@wait = Selenium::WebDriver::Wait.new(:timeout => 60) # seconds #----define wait------
    @@data = Roo::Excel.new("E:\\test1updated.xls") #------ define excel
    @@xls = Roo::Spreadsheet.open('E:\\test1updated.xls')


    def test_Login
    login_page()
    rows = @@xls.sheet(0).count
    2.upto(rows) do |i|
    login()
    end
    end

    def login_page
    sleep(5)
    @@wait.until do @@driver.find_element(:class, " navbar-inner")
    @@driver.find_element(:link, "Login").click
    end

    @@driver.find_element(:id, "txtUserName")
    @@driver.find_element(:id, "txtPassword")


    if @@driver.find_element(:id, "txtUserName").displayed?
    username = @@driver.find_element(:id, "txtUserName")
    password = @@driver.find_element(:id, "txtPassword")
    end

    end

    def login


    2.upto(@@data.last_row) do |row| #------- to read fron second row in excel sheet---------
    username_value = @@data.cell(row, 'A')
    puts username_value
    sleep(5)
    password_value = @@data.cell(row, 'B')
    puts password_value

    puts password_value.to_i
    puts password_value.to_i.to_s
    puts username_value
    puts password_value
    puts "Hi-------------------@@@@@@@@@@@@@@@@@@@@"
    username = @@driver.find_element(:id, "txtUserName")
    password = @@driver.find_element(:id, "txtPassword")

    username.send_keys username_value
    sleep(10)
    password.send_keys password_value.to_i.to_s

    puts "Hi1-------!!!!!!!!!!!!!!!!!!!!!!"
    #------ parse into integer and then into string-----------
    @@driver.find_element(:id, "btnLogin").click
    logout()
    end
    end

    def logout

    @@wait.until { @@driver.find_element(:class, "container")}
    @@driver.find_element(:class, "dropdown-toggle")
    @@driver.find_element(:class, "dropdown-toggle")
    @@driver.find_element(:class, "caret").click
    @@wait.until { @@driver.find_element(:class, "dropdown-menu")}
    @@wait.until { @@driver.find_element(:xpath, ".//*[@id='patient_banner_linkLogout']").click}
    alert = @@driver.switch_to.alert
    alert.accept()
    login_page()
    end

    end


    ReplyDelete
  7. HI Vamshi,
    Your Blogs helps alot in learning selenium..
    I have interview by Tomorrow on 26th sep..
    i need answers for this.
    what are the challenges faced during automation using selenium2? and solution to over come from it?
    what are the bugs one can find the automation?
    what are cross browsers issues? please give me example for each issue?



    Thanks,
    Taj

    ReplyDelete
    Replies
    1. hi khurra how are u
      i very happy to read ur selenium example .
      pls help me in how to read excel file using selenium webdriver
      my email id is bbitharen@gmail.com
      sumit choudhary

      Delete
  8. HI Vamshi,
    First of all i want to thanks for your blogs.Your each post has helped me alot.
    i need answers for some question,

    what are the challenges you faced during automation using selenium2? ant? jenkins? and how to overcome from each challenge?
    what are the cross browser issues? give examples on this topic?
    how to handle multiple browsers in webdriver? if i want to run my testng.xml on more than two browsers,where actually we have to setting to run parallel on different browsers?

    ReplyDelete
    Replies
    1. Challenges faced during automation always depend on the project you are working on . Most of the time issues come with captcha , flash , script executon etc.

      For captcha , we have our development team to disable captcha for specific IP address so we were able to overcome it.

      I couldn't answer most of your questions now.

      Wish you luck for your Interview..!! Give your best :)

      Delete
  9. Hi Vamshi Kurra,

    Thanks for such a nice content for selenium :) , It really helps a lot
    Actually i m fresher in Testing world n having lot of interest in Selenium
    So, Now a days i m struggling with below mention topic , pls help me in this :

    How to Upload File/Photo using “Upload Image Button” in Selenium Webdriver

    WebElement UploadImg = driver.findElement(By.xpath("//*[@id='file_upload_button']"));
    UploadImg.click();
    WebElement frame =driver.switchTo().activeElement();
    frame.sendKeys("d:\5.jpg");

    This code just open system window but it doesn't select any Photo/File

    ReplyDelete
    Replies
    1. Hi Niya,
      I am not sure on which site you are testing it.Can you share the site url on which you tried?

      Here is the sample script:
      driver.get("http://www.freeonlinephotoeditor.com/");
      driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
      driver.findElement(By.id("file")).sendKeys("C:\\Users\\Public\\Pictures\\Sample Pictures\\Desert.jpg");
      driver.findElement(By.name("upload")).submit();

      Delete
  10. Thank You So much For Reply

    Refer a Link for a above problem :
    http://classifieds.sandhira.com/toronto/pet/birds

    For this button , our website use ajax
    hence above written code is not working over.

    ReplyDelete
    Replies
    1. Niya,

      I couldn't find a solution for this till now . I will give it a try and update you If I happen to get a solution :)
      meanwhile , if you happen to get the solution then please do share :)

      Delete
  11. Thanks for reply & help :)
    And i will surly tell you if i get a solution....!

    ReplyDelete
  12. Hi Vamshi , I have query that how to set specif value in slider , i am able to move the slider but not able to set slider on specif value..Hope u can help me in this .. :)

    ReplyDelete
    Replies
    1. Hi Niya,

      Specifying value in slider can be done by using javascript.
      I am not sure which site you are referring but the below code works fine for http://jqueryui.com/slider/ .


      driver.get("http://jqueryui.com/slider/");
      driver.switchTo().frame(0);
      driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
      JavascriptExecutor js = (JavascriptExecutor) driver;
      js.executeScript("document.getElementsByClassName('ui-slider-handle ui-state-default ui-corner-all')[0].setAttribute('style', 'left: 18%;')");

      Delete
  13. Actually i knew the code u have given , however i wanna set specific value in slider , for ex. go to www.myntra.com and set exact 3000 value in slider , According to my knowledge : onces u move and set the slider on 3000 value than it display 3000 in hidden textbox and changing value in that doesn't affect on slider hence, Now we have to achieve this through URL as u can see ...slider value effect in URL . Hope u can help me in this :)

    ReplyDelete
  14. Hi Vamshi , i solved program :D that i asked yesterday.

    ReplyDelete
    Replies
    1. Cool :)

      Did you use javascript executor or any other thing to solve it ?

      Delete
  15. No i just rearrange the URL. and set a slider based on that :)

    ReplyDelete
  16. This comment has been removed by the author.

    ReplyDelete
  17. Hi Vamshi,

    I have one very small doubt. If I want to Click on LOGIN button after entering Username and Password in Facebook login page:

    Does really the below code, clicks on LOGIN button

    driver.findelement(By.Id("loginbutton")).sendkeys(keys.Enter);

    If not, what does actually the above code does?

    ReplyDelete
  18. This comment has been removed by the author.

    ReplyDelete
  19. Hi Vamshi,

    I have one very small doubt. If I want to Click on LOGIN button after entering Username and Password in Facebook login page:

    Does really the below code, clicks on LOGIN button

    driver.findelement(By.Id("loginbutton")).sendkeys(keys.Enter);

    If not, what does actually the above code does?

    ReplyDelete
    Replies
    1. Hi,

      Use the below code for clicking on LOGIN button.

      driver.findElement(By.cssSelector("input[value='Log In']")).submit();

      OR

      driver.findElement(By.cssSelector("input[value='Log In']")).sendKeys(Keys.ENTER);


      In your code , you have not used the correct locator for login button.So it does nothing .
      driver.findelement(By.Id("loginbutton")).sendkeys(keys.Enter);

      Delete
    2. Hi Vamshi,

      Thank you for addressing my Question. When I tried both the code line you have given, I see only 1st submit() code is working whereas 2nd code is functioning same as my code "driver.findelement(By.Id("loginbutton")).sendkeys(keys.Enter);".

      No actions performed on the button. I am very much curious to witness what actually Special Characters do when we pass it via sendKeys().

      Delete
    3. Hi,

      Second code worked for me on ff 26.0 . somehow it is not working on ff 27.0

      Regarding your second question special characters functionality is as same as what they do when you manually send it .

      Ex :
      Below code can refresh a webpage by sending F5 key .
      driver.findElement(By.name("email")).sendKeys(Keys.F5);


      Delete
  20. Hi All,

    Can anybody please help me solve the following issue.

    I have an element on webpage which carry text like this Questions›Create questions where Questions is link type and its very easy to find its locator but the second one 'Create question' is static i.e. its not link type and fixed.

    I'm unable to find the locator for 'Create question' text as it combines with Questions and create a xpath like this .//*[@id='main']/h2"

    I really need to find the locator OR is there any technique which can help me get the partial text of any locator?


    ReplyDelete
    Replies
    1. You can check whether text is present on the webpage ro not by checking sourcecode page .
      ex:
      driver.getPageSource().contains("Create question");

      Hope it helps..!!

      Delete
  21. html code

    /h2
    a href="https://abcd.com/test2/test/public/admin/question/index/index/project_id/1"
    span style="font-size:9pt;">Question/span
    /a
    span style="margin:0px 10px;">›/span
    Create question
    h2/

    ReplyDelete
  22. I was doing one thing and stucked somewhere, Kindly help some one by giving the code details,
    When we are using test ng to fail any test case we are ususally writing assertion method to fail the test case. But after that it's coming out and not executing rest of the test case.
    So I caught that error in try catch block.
    And now all test cases passed,the failed one also.
    But i want to fail the test case and pass all other.So some how i have to tell the reporter to fail the test case with error messege.
    Ho to do that.I know through test ng listener we can do it,but plz tell me details with code(Any example u can give)

    ReplyDelete
  23. I was doing one thing and stucked somewhere, Kindly help some one by giving the code details,
    When we are using test ng to fail any test case we are ususally writing assertion method to fail the test case. But after that it's coming out and not executing rest of the test case.
    So I caught that error in try catch block.
    And now all test cases passed,the failed one also.
    But i want to fail the test case and pass all other.So some how i have to tell the reporter to fail the test case with error messege.
    Ho to do that.I know through test ng listener we can do it,but plz tell me details with code(Any example u can give)

    ReplyDelete
  24. Hi Gourab ,
    If you create every testcase as individual class testNG will run all testcases irrespective of the run-state of previous testcase.
    Also you can use Reporter.log("") to log details of tests in the output file.

    ReplyDelete