public class FileUpload {
public static void main(String[] args) throws InterruptedException, FindFailed {
//Firefox
System.setProperty("webdriver.gecko.driver","C:\\Drivers\\geckodriver-v0.28.0-win64\\geckodriver.exe");
WebDriver driver =new FirefoxDriver();
// System.setProperty("webdriver.chrome.driver","C:\\Drivers\\chromedriver_win32\\chromedriver.exe");
// WebDriver driver=new ChromeDriver();
driver.get("https://opensource-demo.orangehrmlive.com");
//Login
driver.findElement(By.id("txtUsername")).sendKeys("admin");
driver.findElement(By.id("txtPassword")).sendKeys("admin123");
driver.findElement(By.id("btnLogin")).click();
Thread.sleep(3000);
driver.findElement(By.xpath("//*[@id=\"menu_pim_viewPimModule\"]")).click(); //PIM
driver.findElement(By.xpath("//*[@id=\"menu_pim_addEmployee\"]")).click(); //AddEmployee
//Direct
// driver.findElement(By.id("photofile")).sendKeys("C:\\SeleniumPractice\\Sikulifiles\\profilepic.jpg");
// driver.findElement(By.id("photofile")).click();
WebElement browse=driver.findElement(By.id("photofile"));
JavascriptExecutor js=(JavascriptExecutor)driver;
js.executeScript("arguments[0].click();",browse);
//Sikuli code starts here
Pattern fileInputTextBox=new Pattern("C:\\SeleniumPractice\\Sikulifiles\\filetxtbox.png");
Pattern openButton=new Pattern("C:\\SeleniumPractice\\Sikulifiles\\openbtn.png");
Screen s=new Screen();
s.wait(fileInputTextBox,3);
s.type(fileInputTextBox,"C:\\SeleniumPractice\\Sikulifiles\\profilepic.jpg");
s.click(openButton);
}
}
-----------------------console window--------------------------
1607914215045 geckodriver INFO Listening on 127.0.0.1:30146
1607914215733 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "--marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\mailf\\AppData\\Local\\Temp\\rust_mozprofileCXKshL"
Can't find symbol 'eglSwapBuffersWithDamageEXT'.
Can't find symbol 'eglSetDamageRegionKHR'.
JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory.
console.warn: SearchSettings: "get: No settings file exists, new profile?" (new Error("", "(unknown module)"))
1607914217827 Marionette INFO Listening on port 60225
1607914217878 Marionette WARN TLS certificate errors will be ignored for this session
Dec 13, 2020 8:50:17 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Exception in thread "main" FindFailed: C:/SeleniumPractice/Sikulifiles/filetxtbox.png: (979x38) in S(0)[0,0 1504x1003] E:Y, T:3.0
Line 2277, in file Region.java
at org.sikuli.script.Region.wait(Region.java:2277)
at day20.FileUpload.main(FileUpload.java:56)