0

I have make 3 function for blank data,invaliddata and validdata.

I have user autoit for the upload the the file from the window.

At the debug time script is run properly but at the run time it displays the below error.

Code:

    [![package abc;
    
    import java.io.IOException;
    
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.support.ui.Select;
    import org.testng.annotations.BeforeTest;
    import org.testng.annotations.Test;
    
    public class Profile {
    
        Setup s1=new Setup();
        Login l1=new Login();
        
        @BeforeTest
        public void setup()
        {
            s1.openbroweser();
            
        }
        @Test(priority=1)
        public void profile()
        {
            s1.getdriver().get("google.com");
            WebElement email=s1.getdriver().findElement(By.name("email"));
            email.clear();
            email.sendKeys("[email protected]");
            
            WebElement password=s1.getdriver().findElement(By.name("password"));
            password.clear();
            password.sendKeys("heena1");
            
            WebElement signin=s1.getdriver().findElement(By.id("m_login_signin_submit"));
            signin.click();
        }
        
        @Test(priority=2)
        public void blankdata() throws InterruptedException, IOException
        {
            Thread.sleep(3000);
            WebElement pic=s1.getdriver().findElement(By.className("form-control"));
            pic.click();
            Thread.sleep(5000);
            Runtime.getRuntime().exec("C:\\Users\\Rutvi \\Desktop\\fileupload.exe");
            
            WebElement name=s1.getdriver().findElement(By.name("name"));
            name.clear();
            name.sendKeys(" ");
            
            WebElement phno=s1.getdriver().findElement(By.name("phone")); 
            phno.clear();
            phno.sendKeys(" ");
            
            WebElement comname=s1.getdriver().findElement(By.name("company_name"));
            comname.clear();
            comname.sendKeys(" ");
            
            WebElement vatno=s1.getdriver().findElement(By.name("vat_number"));
            vatno.clear();
            vatno.sendKeys(" ");
            
            WebElement cocno=s1.getdriver().findElement(By.name("coc_number"));
            cocno.clear();
            cocno.sendKeys(" ");
            
            WebElement address=s1.getdriver().findElement(By.name("address"));
            address.clear();
            address.sendKeys(" ");
            
            WebElement postalcode=s1.getdriver().findElement(By.name("postal_code"));
            postalcode.clear();
            postalcode.sendKeys(" ");
            
            WebElement provience=s1.getdriver().findElement(By.name("provincie"));
            Select dropdown= new Select(provience);
        //  dropdown.selectByIndex(3);
            
            WebElement save=s1.getdriver().findElement(By.id("update_user_profile"));
            save.click();       
        }
        
        @Test(priority=3)
        public void invaliddata() throws InterruptedException, IOException
        {
            
            WebElement pic=s1.getdriver().findElement(By.className("form-control"));
            pic.click();
            Thread.sleep(5000);
            Runtime.getRuntime().exec("C:\\Users\\Rutvi\\Desktop\\wrongfileupload.exe");
            
            WebElement name=s1.getdriver().findElement(By.name("name"));
            name.clear();
            name.sendKeys("Rutvi");
            
            WebElement phno=s1.getdriver().findElement(By.name("phone"));
            phno.clear();
            phno.sendKeys("9012345678");
            
            WebElement comname=s1.getdriver().findElement(By.name("company_name"));
            comname.clear();
            comname.sendKeys("search native");
            
            WebElement vatno=s1.getdriver().findElement(By.name("vat_number"));
            vatno.clear();
            vatno.sendKeys("123454");
            
            WebElement cocno=s1.getdriver().findElement(By.name("coc_number"));
            cocno.clear();
            cocno.sendKeys("89798");
            
            WebElement address=s1.getdriver().findElement(By.name("address"));
            address.clear();
            address.sendKeys("ahmedabad");
            
            WebElement postalcode=s1.getdriver().findElement(By.name("postal_code"));
            postalcode.clear();
            postalcode.sendKeys("1234AS");
            
            WebElement provience=s1.getdriver().findElement(By.name("provincie"));
            Select dropdown= new Select(provience);
            dropdown.selectByIndex(3);
            
            WebElement save=s1.getdriver().findElement(By.id("update_user_profile"));
            save.click();
        
        }
        
        @Test(priority=4)
        public void validdata() throws InterruptedException, IOException
        {
            Thread.sleep(3000);
            WebElement pic=s1.getdriver().findElement(By.className("form-control"));
            pic.click();
            
            Runtime.getRuntime().exec("C:\\Users\\Rutvi\\Desktop\\fileupload.exe");
            Thread.sleep(5000);
            WebElement name=s1.getdriver().findElement(By.name("name"));
            name.clear();
            name.sendKeys("Rutvi");
            
            WebElement phno=s1.getdriver().findElement(By.name("phone"));
            phno.clear();
            phno.sendKeys("9012345678");
            
            WebElement comname=s1.getdriver().findElement(By.name("company_name"));
            comname.clear();
            comname.sendKeys("search native");
            
            WebElement vatno=s1.getdriver().findElement(By.name("vat_number"));
            vatno.clear();
            vatno.sendKeys("123454");
            
            WebElement cocno=s1.getdriver().findElement(By.name("coc_number"));
            cocno.clear();
            cocno.sendKeys("89798");
            
            WebElement address=s1.getdriver().findElement(By.name("address"));
            address.clear();
            address.sendKeys("ahmedabad");
            
            WebElement postalcode=s1.getdriver().findElement(By.name("postal_code"));
            postalcode.clear();
            postalcode.sendKeys("1234AS");
            
            WebElement provience=s1.getdriver().findElement(By.name("provincie"));
            Select dropdown= new Select(provience);
            dropdown.selectByIndex(3);
            
            WebElement save=s1.getdriver().findElement(By.id("update_user_profile"));
            save.click();
        
        }
        
    }

Screenshot of error

5
  • Can you show us the error in text? Not in screen shot.
    – Alexey R.
    Aug 14, 2018 at 10:26
  • @AlexeyR.org.openqa.selenium.WebDriverException: unknown error: Element <input type="file" class="form-control m-input" name="file" value="1534229067.jpg"> is not clickable
    – Rutvi Soni
    Aug 14, 2018 at 11:17
  • Other tests have Thread.sleep as the first line while the failed one doesn't/ Try add sleep period before the tests starts.
    – Alexey R.
    Aug 14, 2018 at 11:20
  • i have try with that but display same error
    – Rutvi Soni
    Aug 14, 2018 at 11:23
  • It probably is not your reported error, but the line Runtime.getRuntime().exec("C:\\Users\\Rutvi \\Desktop\\fileupload.exe"); contains an extra space after your name. Which line, exactly, is reporting the error? There's a LOT of lines in your sample code. Aug 14, 2018 at 13:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.