SACHIN's Profile
Vice Professor
533
Points

Questions
0

Answers
30

  • Vice Professor Asked on December 12, 2015 in Selenium WebDriver.

    Captcha in the form of image can not break (As of now).

    • 936 views
    • 1 answers
    • 0 votes
  • Vice Professor Asked on February 26, 2015 in Selenium WebDriver.

    Hello,

    Please go through and if it didn’t work then let me know 🙂 .

    URL: LINK

    This answer accepted by Selenium. on February 28, 2015 Earned 15 points.

    • 1070 views
    • 1 answers
    • 0 votes
  • Vice Professor Asked on February 24, 2015 in Selenium WebDriver.

    Hello Shashank,

    TestNG is an open source framework. It supports parametrization, data driven testing, parallel execution. JUnit is not much flexible for these.

    Before I was fan of Junit but after using TestNG I felt TestNG is better for selenium.

    Please go through this link.

    TestNG: http://testng.org/doc/index.html

    • 1332 views
    • 1 answers
    • 0 votes
  • Vice Professor Asked on December 30, 2014 in Selenium WebDriver.

    Hi Uday,

    DropDown means we select value from the dropdown, and every dropdown will be having “select” tag. You are getting  “select” but was “div”” error because, the tag is “div” instead “select”.

    And Dropdown and serach/text fields are different. Your object is text field but NOT dropdown field.

    Ex: See below code and you can see the select tag from this use can select the dropdown value. URL: https://www.facebook.com/

     
    1. <select id=”month class=”_5dba name=”birthday_month>
    2. <option selected=”1 value=”0>Month</option>
      <option value=”1>Jan</option>
      <option value=”2>Feb</option>
      <option value=”3>Mar</option>
      <option value=”4>Apr</option>
      <option value=”5>May</option>
      <option value=”6>Jun</option>
      <option value=”7>Jul</option>
      <option value=”8>Aug</option>
      <option value=”9>Sep</option>
      <option value=”10>Oct</option>
      <option value=”11>Nov</option>
      <option value=”12>Dec</option>
    3. </select>
     

    Hope you got the answer.

    • 6290 views
    • 4 answers
    • 1 votes
  • Vice Professor Asked on December 16, 2014 in Selenium WebDriver.

    Hello Murali,

    The answer is quite simple (As per me), create separate method for each validation, for ex:

    
    import java.util.concurrent.TimeUnit;
    
    import org.openqa.selenium.*;
    
    import org.openqa.selenium.firefox.FirefoxDriver;
    
    import org.testng.annotations.AfterMethod;
    
    import org.testng.annotations.AfterTest;
    
    import org.testng.annotations.Test;
    public class Validations {
    
    private WebDriver driver;
    @Test
    
    public void valid() throws Exception {
    
    driver = new FirefoxDriver();
    
    driver.get("https://accounts.google.com/");
    
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    
    driver.findElement(By.id("Email")).sendKeys("abc");
    
    driver.findElement(By.id("Passwd")).sendKeys("xyz");
    
    driver.findElement(By.id("signIn")).click();
    
    }
    @Test
    
    public void invalid_BlankPassword() throws Exception {
    
    driver = new FirefoxDriver();
    
    driver.get("https://accounts.google.com/");
    
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    
    driver.findElement(By.id("Email")).sendKeys("abc");
    
    driver.findElement(By.id("Passwd")).sendKeys("");
    
    driver.findElement(By.id("signIn")).click();
    
    }
    @AfterMethod
    
    public void tearDown() throws Exception {
    
    driver.quit();
    
    }
    
    }
    
    
    • 15693 views
    • 1 answers
    • 0 votes
  • Vice Professor Asked on December 10, 2014 in Selenium WebDriver.

    Hi Rajan,

    Please refer these urls: URL  and URL2

    Thanks,
    Sachin

    • 539 views
    • 1 answers
    • 0 votes
  • Vice Professor Asked on November 22, 2014 in Selenium WebDriver.

    Hi Sumit,

    I am not 100% sure what is your question, but as per my understanding posting my code. Please let me know this will for you or not.

    
    import java.util.concurrent.TimeUnit;
    
    import org.openqa.selenium.By;
    
    import org.openqa.selenium.WebDriver;
    
    import org.openqa.selenium.firefox.FirefoxDriver;
    
    import org.testng.annotations.Test;
    public class GetAttribute {
    @Test
    
    public void GetAttributeValue() throws InterruptedException
    
    {
    
    WebDriver d = new FirefoxDriver();
    
    d.manage().window().maximize();
    
    d.get("http://www.facebook.com");
    
    d.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    
    String username= d.findElement(By.xpath(".//*[@id='email']")).getAttribute("value");
    
    System.out.println("Username is: "+ username);
    
    if(username.isEmpty()){
    
    d.findElement(By.xpath(".//*[@id='email']")).sendKeys("USERNAME");
    
    System.out.println("USER NAME is: " + d.findElement(By.xpath(".//*[@id='email']")).getAttribute("value"));
    
    }else{
    
    System.out.println("User Name Not Entered");
    
    d.quit();
    
    }
    
    }
    
    }
    
    
    • 669 views
    • 1 answers
    • 0 votes
  • Vice Professor Asked on November 16, 2014 in Selenium WebDriver.

    Hi,

    Please use below code, if not worked then let me know, if worked then ACCEPT the answer 🙂 .

    
    import java.util.List;
    
    import org.openqa.selenium.By;
    
    import org.openqa.selenium.WebDriver;
    
    import org.openqa.selenium.WebElement;
    
    import org.openqa.selenium.firefox.FirefoxDriver;
    
    import org.openqa.selenium.support.ui.ExpectedConditions;
    
    import org.openqa.selenium.support.ui.WebDriverWait;
    
    import org.testng.annotations.Test;
    public class Auto_Suggestions {
    
    @Test
    
    public void select() throws InterruptedException
    
    {
    
    WebDriver d = new FirefoxDriver();
    
    d.manage().window().maximize();
    
    d.get("http://www.monsterindia.com/");
    d.findElement(By.id("fts_id")).sendKeys("software");
    WebElement link = d.findElement(By.id("ui-id-1"));
    
    List<WebElement> links = link.findElements(By.tagName("li"));
    
    for(int i=0; i<links.size();i++)
    
    {
    
    System.out.println(links.get(i).getText());
    
    }
    
    WebElement myDynamicElement = (new WebDriverWait(d, 10)).until(ExpectedConditions.presenceOfElementLocated(By.id("ui-id-11")));
    
    d.findElement(By.id("ui-id-11")).click();
    
    d.findElement(By.className("mn_findbtn")).click();
    }
    
    }
    
    
    • 1323 views
    • 3 answers
    • 0 votes
  • Vice Professor Asked on October 5, 2014 in Selenium WebDriver.

    Hello Allen,

    Try below code, this may help you.

    // Get a handle to the open alert, prompt or confirmation

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

    //Will Click on OK button.

    
    alert.accept();
    
    

    // Will click on Cancel button.

    
    alert.dismiss()
    
    

    This answer accepted by Richard Allen. on October 6, 2014 Earned 15 points.

    • 788 views
    • 4 answers
    • 0 votes
  • Vice Professor Asked on October 3, 2014 in Selenium WebDriver.

    Hello Allen,

    Please use below code.

    System.setProperty(“webdriver.chrome.driver”, (System.getProperty(“user.dir”)+”/chromedriver.exe”));
    ChromeOptions options = new ChromeOptions();
    options.addArguments(“–test-type”);
    WebDriver driver = new ChromeDriver(options);
    driver.get(“https://google.com/”);

    • 2507 views
    • 4 answers
    • 0 votes
  • Vice Professor Asked on October 1, 2014 in Selenium WebDriver.

    Hello Allen,

     

    Please try with below code. And let me know whether it will work or not?.
    import java.util.concurrent.TimeUnit;
     import org.testng.annotations.Test;
     import org.testng.annotations.BeforeMethod;
     import org.testng.annotations.AfterMethod;
     import org.openqa.selenium.By;
     import org.openqa.selenium.WebDriver;
     import org.openqa.selenium.WebElement;
     import org.openqa.selenium.chrome.ChromeDriver;
    public class NewTest {
     public WebDriver driver;
    @Test
    public void main() {
    //Setting Variables
     String strUsername = "name";
     String strPassword = "PW";
    WebElement txtUsername = driver.findElement(By.id("username"));
     txtUsername.sendKeys(strUsername);
     WebElement txtPassword = driver.findElement(By.id("passwd"));
     txtPassword.sendKeys(strPassword);
     WebElement txtLogin = driver.findElement(By.id(".save"));
     txtLogin.click();
    }
    @BeforeMethod
    public void beforeMethod() {
    System.setProperty("webdriver.chrome.driver","D:/Selenium/Drivers/chromedriver.exe");
    driver = new ChromeDriver(); //Chanhe is in this line (Removed WebDriver).
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    //Navigate to Test A
    driver.get("https://login.yahoo.com");
    }
    @AfterMethod
    public void afterMethod() {
    driver.quit();
    }
    }
    

     

    • 800 views
    • 4 answers
    • 0 votes
  • Vice Professor Asked on September 30, 2014 in Selenium WebDriver.

    If you want to use one class and multiple methods then use below code and try.

    @BeforeTest
     public static void beforeMethod() {
     driver= new FirefoxDriver();
     }
    @Test
     public void main1() {
     driver.get("http://indianrail.gov.in/pnr_Enq.html");
     driver.findElement(By.id("element")).sendKeys("1234567890");
     String captcha = driver.findElement(By.id("txtCaptchaDiv")).getText();
     System.out.println("Captcha is: " +captcha);
     driver.findElement(By.id("txtInput")).sendKeys(captcha);
     }
     @Test
     public void main2() {
     driver.findElement(By.className("btn_style")).click();
     }
     @Test
     public void main3() {
     System.out.println("The title is: " +driver.getTitle());
     }
    

     

    • 953 views
    • 2 answers
    • 0 votes
  • Vice Professor Asked on September 26, 2014 in Selenium WebDriver.

    Hi Raghul,

    Please go through the below links and you may get some idea and how to deal with to identify an element, text, etc..

    http://stackoverflow.com/questions/3655549/xpath-containstext-some-string-doesnt-work-when-used-with-node-with-more

    http://stackoverflow.com/questions/1390568/how-to-match-attributes-that-contain-a-certain-string

    • 693 views
    • 3 answers
    • 0 votes
  • Vice Professor Asked on September 26, 2014 in Selenium WebDriver.

    @Vishal: We can do automation testing onCaptcha” also, but few one only for example.

    driver = new FirefoxDriver();
    driver.get(“http://indianrail.gov.in/pnr_Enq.html”);
    driver.findElement(By.id(“element”)).sendKeys(“1234567890”);
    String captcha = driver.findElement(By.id(“txtCaptchaDiv”)).getText();
    System.out.println(captcha);
    driver.findElement(By.id(“txtInput”)).sendKeys(captcha);

    This answer accepted by anu17. on October 30, 2014 Earned 15 points.

    • 924 views
    • 3 answers
    • 1 votes
  • Vice Professor Asked on September 24, 2014 in Selenium WebDriver.

    Hi Surekha,

    Please go through the below links. These links may help you.

    http://www.tutorialspoint.com/junit/junit_test_framework.htm

    This answer accepted by surekha. on October 27, 2014 Earned 15 points.

    • 419 views
    • 2 answers
    • 0 votes
  • Vice Professor Asked on September 20, 2014 in Selenium WebDriver.

    Hi,

    Create more than 2 methods and use @Test annotation with methods. Or please post your code if below is not solution for your query. I gave the solution based on what I understood from your query.

    @Test(priority=0)
    public void method1() {
    ……………. //Your code
    }

    @Test(priority=1)
    public void method2() {
    …………….//Your code
    }

    So on………!!!!!

    • 652 views
    • 3 answers
    • 0 votes
  • Vice Professor Asked on September 20, 2014 in Selenium WebDriver.

    Try “driver.switchTo().window("windowName");” and go through these links.

    Links:
    http://www.toolsqa.com/selenium-webdriver/switch-commands/

    http://sqa.stackexchange.com/questions/8416/how-to-switch-handle-particular-popup-window-when-multiple-popup-are-opened-an

    • 754 views
    • 2 answers
    • 0 votes
  • Vice Professor Asked on September 20, 2014 in Selenium WebDriver.

    Hi Roshan,

    Kindly post your code or just try below code in your script or go through the below links you may get some idea.

    driver.switchTo().frame(“frameName”);

    Links:

    http://www.toolsqa.com/selenium-webdriver/switch-commands/

    http://sqa.stackexchange.com/questions/8416/how-to-switch-handle-particular-popup-window-when-multiple-popup-are-opened-an

    • 655 views
    • 1 answers
    • 0 votes
  • Vice Professor Asked on September 19, 2014 in Selenium WebDriver.

    Hi Roshan,

    You need to change the eclipse (If you are using eclipse ide) setting to “UTF-8” then it will support. Below are the steps.

    Project–> Properties–> Resource–> Select “Other” radio button at “Text file encoding” –> and select “UTF-8” from–> apply–> Ok.

    Try and let me know :).

    This answer accepted by roshan3506. on September 20, 2014 Earned 15 points.

    • 625 views
    • 2 answers
    • 0 votes
  • Vice Professor Asked on September 16, 2014 in Selenium WebDriver.

    Now check. Below highlighted are the changes.

    And let me know the result 🙂 .

    
    @Test
    public void test() {
    
    d.findElement(By.id("txtUserName")).click();
    d.findElement(By.id("Password")).click();
    d.findElement(By.className("button postfix")).click();
    
    }
    
     
    
    @BeforeClass
    
    @Parameters("browser") //You have given at @Test annotation
    
    public void beforeClass(String browser) {
    
    if(browser.equalsIgnoreCase("firefox"))
    {
    d=new FirefoxDriver();
    }
    else if(browser.equalsIgnoreCase("chrome"))
    {
    System.setProperty("webdriver.chrome.driver", "D:/Selenium/Drivers/chromedriver.exe"); //Should be small letters always (webdriver)
    d= new ChromeDriver();
    }
    d.get("http://www.univoxcommunity.com");
    }
    
    

    Thanks,
    Sachin

    This answer accepted by snpanigrahi9. on October 26, 2014 Earned 15 points.

    • 672 views
    • 1 answers
    • 1 votes
  • Vice Professor Asked on September 13, 2014 in Selenium WebDriver.

    Hi Itsivaprasad,

    If you share HTML, then we can provide you the example program and hope after seeing below methods you can do it. 🙂

    Use other identifier to identify the object or use xpath, for example:

    starts-with

    If your dynamic element’s ids have the format where button id=”continue-12345″ where 12345 is a dynamic number you could use the following

    XPath: //button[starts-with(@id, 'continue-')]

    contains

    Sometimes an element gets identified by a value that could be surrounded by other text, then contains function can be used.

    XPath: //input[contains(@class, 'suggest')]

    • 777 views
    • 2 answers
    • 0 votes
    • 669 views
    • 2 answers
    • 0 votes
  • Vice Professor Asked on September 7, 2014 in Selenium WebDriver.

    One of the many answer is: use Xpath in this condition 🙂 , for example.
     

    
    .//*[@id='default_products_page_container']/div[3]/div[2]/form/div[2]/div[1]/span/input
    .//*[@id='default_products_page_container']/div[4]/div[2]/form/div[2]/div[1]/span/input
    

    In another question I saw that you are working on MDF and I think you required generic code, but sorry friend I don’t know that 🙁 .

    Other people will suggest you the different solutions..

    • 1008 views
    • 6 answers
    • 2 votes
    • 1946 views
    • 4 answers
    • 0 votes
  • Vice Professor Asked on September 5, 2014 in Selenium WebDriver.

    Please post your code or xpath, then we can give the solution for this. :)..

    • 533 views
    • 3 answers
    • 0 votes