Not able to take the screenshot in aws device farm for android appication automation testing - selenium

Can you please help me to resolve this screenshot issue. I have written the method which I am calling on every screen but I am getting an error while the test is running. I have tried on this question also but I could not find the answers. Here is my code for screenshot
public static boolean takeScreenshotAtEndOfTest(AndroidDriver<MobileElement> driver) {
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
String screenshotDirectory = System.getenv("DEVICEFARM_LOG_DIR");
File screenshot = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
return screenshot.renameTo(new File(screenshotDirectory, String.format("%s.png", timestamp)));
}
Here is the error which I am getting :
startApplication org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: The request to /screenshot has failed Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'ip-172-31-13-65', ip: '172.31.13.65', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-139-generic', java.version: '1.8.0_151' Driver info: io.appium.java_client.android.AndroidDriver Capabilities {app: /tmp/scratchjCnSt_.scratch/..., appPackage: com.company, autoGrantPermissions: true, databaseEnabled: false, desired: {app: /tmp/scratchjCnSt_.scratch/..., autoGrantPermissions: true, deviceName: Android, platformName: android, udid: HT85G1A03343}, deviceApiLevel: 28, deviceManufacturer: Google, deviceModel: Pixel 2, deviceName: HT85G1A03343, deviceScreenDensity: 420, deviceScreenSize: 1080x1920, deviceUDID: HT85G1A03343, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, pixelRatio: 2.625, platform: LINUX, platformName: Android, platformVersion: 9, statBarHeight: 63, takesScreenshot: true, udid: HT85G1A03343, viewportRect: {height: 1731, left: 0, top: 63, width: 1080}, warnings: {}, webStorageEnabled: false} Session ID: 61633183-071b-4c90-9173-addf700d60b7 at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552) at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:45) at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1) at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1) at org.openqa.selenium.remote.RemoteWebDriver.getScreenshotAs(RemoteWebDriver.java:295) at com.name.impl.CommonImpl.takeScreenshotAtEndOfTest(CommonImpl.java:207)

Related

Exception in thread "main" org.openqa.selenium.InvalidArgumentException: invalid argument

I am getting the following error after running the code:
Exception in thread "main" org.openqa.selenium.InvalidArgumentException: invalid argument
(Session info: chrome=103.0.5060.114)
Build info: version: '4.3.0', revision: 'a4995e2c09*'
System info: host: 'SADAF-RAUF', ip: '192.168.1.55', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.15'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [99bdbf5c25fd5790a4c9901c3f7f1dde, clickElement {id=1d9cbee0-b4cb-4993-b271-3a3e36c42165}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 103.0.5060.114, chrome: {chromedriverVersion: 103.0.5060.53 (a1711811edd7..., userDataDir: C:\Users\Sadaf\AppData\Loca...}, goog:chromeOptions: {debuggerAddress: localhost:64336}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: WINDOWS, proxy: Proxy(), se:cdp: ws://localhost:64336/devtoo..., se:cdpVersion: 103.0.5060.114, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Element: [[ChromeDriver: chrome on WINDOWS (99bdbf5c25fd5790a4c9901c3f7f1dde)] -> id: uploadPicture]
Session ID: 99bdbf5c25fd5790a4c9901c3f7f1dde
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:200)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:133)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:53)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:184)
at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:167)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:142)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:569)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:257)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:78)
at com.autoit.FileUpload.upload(FileUpload.java:25)
at com.autoit.FileUpload.main(FileUpload.java:32)code image
//use Sendkeys
driver.findElement(By.id("uploadPicture")).sendKeys("L:\Software\wrar511b1.exe");

Selenium: Unable to click a button of custom popup

I tried to click a button of select files then submit button in the popup but it neither recognizes the popup nor the button in it.
For selecting the modal-content
driver.switchTo().frame("modal-content");
message:
Exception in thread "main" org.openqa.selenium.NoSuchFrameException: No frame element found by name or id modal-content
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'RAUNAK-MA', ip: '192.168.2.200', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.frame(RemoteWebDriver.java:885)
at newpackage1.newTest.main(newTest.java:41)
post removing the switch to and directly selecting the element
WebElement LinkCheckerbutton1 = driver.findElement(By.id("linkCheckerFileUpload"));
LinkCheckerbutton1.click();
Results:
Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"id","selector":"linkCheckerFileUpload"}
(Session info: chrome=73.0.3683.103)
(Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'RAUNAK-MA', ip: '192.168.2.200', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.46.628402 (536cd7adbad73a..., userDataDir: C:\Users\RAUNAK~1.MAS\AppDa...}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:65266}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), rotatable: false, setWindowRect: true, strictFileInteractability: false, takesHeapSnapshot: true, takesScreenshot: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unexpectedAlertBehaviour: ignore, unhandledPromptBehavior: ignore, version: 73.0.3683.103, webStorageEnabled: true}
Session ID: 889a04bb870854aef890e9dcb55c7508
*** Element info: {Using=id, value=linkCheckerFileUpload}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:372)
at org.openqa.selenium.By$ById.findElement(By.java:188)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
at newpackage1.newTest.main(newTest.java:43)
This error message...
Exception in thread "main" org.openqa.selenium.NoSuchFrameException: No frame element found by name or id modal-content
...implies that there is no frame element by the id or name modal-content.
However it gives us a hint the desired element is within a Modal Dialog Box.
So to locate the element you have to induce WebDriverWait for the elementToBeClickable() and you can use either of the following Locator Strategies:
cssSelector:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("#linkCheckerFileUpload"))).click();
xpath:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//*[id='linkCheckerFileUpload']"))).click();

Geb not pointing to right page after closing confirm dialog in new window

I am doing test automation with geb in groovy, curently dealing with scenario like:
First, I am in parent window, from there I open new window and do some search there, Clicking on the search result generates a confirm dialogue and updates the value in parent page, Bypassing the dialog with withConfirm(). then I come to parent window but nothing executes after that. I think geb is getting confused between pages.
In parent Page
open new window
search for something
click on the first search result
clicking on it opens a confirm dialog
click okay and close the new window
continue with parent window
My code looks like:
withNewWindow(close: false,wait:true,{$(button that opens new window).click()}) {
waitFor{
title == "title"
}
withConfirm(wait: true){$(cause to open confirm dialog).click()}
}
$("input[name='button'][id='SAVE_FOOTER']").click()
}
Error:
Caught: org.openqa.selenium.NoSuchWindowException: Browsing context has been discarded
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'DESKTOP-NAFK3F3', ip: '10.1.10.195', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 65.0.2, javascriptEnabled: true, moz:accessibilityChecks: false, moz:geckodriverVersion: 0.24.0, moz:headless: false, moz:processID: 12824, moz:profile: C:\Users\Dell\AppData\Local..., moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, platformVersion: 10.0, rotatable: false, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: 2c0c768c-785f-49d4-bdff-186566e722dd
org.openqa.selenium.NoSuchWindowException: Browsing context has been discarded
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'DESKTOP-NAFK3F3', ip: '10.1.10.195', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 65.0.2, javascriptEnabled: true, moz:accessibilityChecks: false, moz:geckodriverVersion: 0.24.0, moz:headless: false, moz:processID: 12824, moz:profile: C:\Users\Dell\AppData\Local..., moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, platformVersion: 10.0, rotatable: false, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: 2c0c768c-785f-49d4-bdff-186566e722dd
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at geb.js.JavascriptInterface.execjs(JavascriptInterface.groovy:66)
at geb.js.JavascriptInterface.exec(JavascriptInterface.groovy:56)
at geb.js.DefaultAlertAndConfirmSupport.popLastDialogFunctionOnto(DefaultAlertAndConfirmSupport.groovy:114)
at geb.js.DefaultAlertAndConfirmSupport.captureDialog(DefaultAlertAndConfirmSupport.groovy:168)
at geb.js.DefaultAlertAndConfirmSupport.captureConfirm(DefaultAlertAndConfirmSupport.groovy:182)
at geb.js.DefaultAlertAndConfirmSupport.withConfirm(DefaultAlertAndConfirmSupport.groovy:54)
at geb.js.DefaultAlertAndConfirmSupport.withConfirm(DefaultAlertAndConfirmSupport.groovy)
at geb.js.AlertAndConfirmSupport$withConfirm.call(Unknown Source)
at geb.Page.withConfirm(Page.groovy:130)
at geb.Browser.methodMissing(Browser.groovy:249)
at geb.Browser.invokeMethod(Browser.groovy)
at CRMPageExample$_run_closure1$_closure3.doCall(CRMPageExample.groovy:149)
at CRMPageExample$_run_closure1$_closure3.doCall(CRMPageExample.groovy)
at geb.Browser.withNewWindow(Browser.groovy:798)
at CRMPageExample$_run_closure1.doCall(CRMPageExample.groovy:137)
at CRMPageExample$_run_closure1.doCall(CRMPageExample.groovy)
at geb.Browser.drive(Browser.groovy:128)
at geb.Browser$drive$0.callStatic(Unknown Source)
at geb.Browser.drive(Browser.groovy:98)
at geb.Browser$drive.call(Unknown Source)
at CRMPageExample.run(CRMPageExample.groovy:97)
1552494416789 Marionette INFO Stopped listening on port 52107
[Parent 12824, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 332
[Child 2628, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 332
[Child 2628, Chrome_ChildThread] WARNING: pipe error: 109: file [Parent 12824, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 332
[Child 8068, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 332
[Child 8068, Chrome_ChildThre
###!!! [Child][MessageChannel::SendAndWait] Error: Channel error: cannot send/recv
Methods I tried but seems useless
waitFor{
withwindow{Parent window}){true}
}
This looks like a potantial issue in Geb alert handling while switching windows. Would you do me a favour please and post this as an issue in the tracker including the code and stacktraces you provided? I’ll take a look when I’m back from holidays in a couple of weeks.

Getting TimeOutException in selenium due to this unable to switch to third window in IE

Exception in thread "main" org.openqa.selenium.TimeoutException: Timed out
waiting for page to load.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-
14T08:25:48'
System info: host: 'INGGNED89DP882', ip: '10.197.131.45', os.name: 'Windows
10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities {acceptInsecureCerts: false, browserName: internet explorer,
browserVersion: 11, javascriptEnabled: true, pageLoadStrategy: normal,
platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), se:ieOptions:
{browserAttachTimeout: 0, elementScrollBehavior: 0, enablePersistentHover:
true, ie.browserCommandLineSwitches: , ie.ensureCleanSession: true,
ie.fileUploadDialogTimeout: 3000, ie.forceCreateProcessApi: false,
ignoreProtectedModeSettings: true, ignoreZoomSetting: false, initialBrowserUrl:
http://localhost:46027/, nativeEvents: true, requireWindowFocus: false},
setWindowRect: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}}
Session ID: 908d30d6-dc3f-4ac8-a1ca-1ddfc060b716
Getting above exception in Internet Explorer Windows 10 , java.version: '1.8.0_60'
try to use the explicit wait based on the condition
WebDriverWait wait = new WebDriverwait(driver,30);
wait.Until(ExpectedCondtions.VisibilityofemementlocatedBy(yourxpath));

"cannot focus element" exception while trying to upload an attachment using selenium

While trying to upload an attachment, trying to send the keys instead of opening the OS based file explorer window as sending the path to the file would be easy.
Tried with different element identifiers, still not able to send the keys. mentioned the element HTML below.
Attached the image of element.
Tried Below Xpath,
//*[#id='fileListVideo']//*[starts-with(#class,'qq-upload-button')]
Error Log:
org.openqa.selenium.WebDriverException: unknown error: cannot focus element
(Session info: chrome=66.0.3359.181)
(Driver info: chromedriver=2.39.562713 (dd642283e958a93ebf6891600db055f1f1b4f3b2),platform=Mac OS X 10.13.4 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
System info: host: 'nagarjunaMBP.local', ip: 'fe80:0:0:0:c2e:b816:67ae:922b%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.4', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.39.562713 (dd642283e958a9..., userDataDir: /var/folders/g4/dylg4g7s7wb...}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: MAC, platformName: MAC, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 66.0.3359.181, webStorageEnabled: true}
Session ID: 38b991ebd4acf37fd0aefaef902853f9
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:276)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:51)
at com.sun.proxy.$Proxy17.sendKeys(Unknown Source)
at actions.PublishBroadcast.MediaLibAction.uploadVideos(MediaLibAction.java:76)
at stepDefinitions.Publish.SDMediaLibrary.Upload_an_Image(SDMediaLibrary.java:43)
at ✽.When Upload an Image(features/publish/mediaLibrary/MediaLibrary.feature:10)
If you are trying to upload a file, and the page uses the standard upload mechanisms provided by HTML, you can do this directly with Selenium itself. The standard HTML mechanism is with an <input type=‘file’> element. Once you’ve found that file upload element on the page, you can use element.sendKeys(“full/path/and/file/name/here”);
where element would be :
WebElement element = driver.findElement(By.cssSelector(input[type='file']));
I was trying with the path to div which will not accept the values. So changes the path to input value //*[#id='fileList']//*[#type='file'] or //*[#id='fileList']//input[#type='file'] this worked.
Thanks to #Andersson