1

i have a modal to upload images.when i click on upload image it is navigating to local computer and then pick the specified image. am getting an error in after navigating to local computer.

error:

Message: Failed: unknown error: Element is not clickable at point (736, 187). Other element would receive the click: ... (Session info: chrome=54.0.2840.99) (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 10.0.14393 x86_64) Stack: WebDriverError: unknown error: Element is not clickable at point (736, 187). Other element would receive the click: ... (Session info: chrome=54.0.2840.99) (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 10.0.14393 x86_64) at WebDriverError (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:27:5) at Object.checkLegacyResponse (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:639:15) at parseHttpResponse (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:538:13) at client_.send.then.response (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:472:11) at ManagedPromise.invokeCallback_ (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1379:14) at TaskQueue.execute_ (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2913:14) at TaskQueue.executeNext_ (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2896:21) at asyncRun (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2820:25) at C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:639:7 at process._tickCallback (internal/process/next_tick.js:103:7) From: Task: WebElement.click() at Driver.schedule (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:377:17) at WebElement.schedule_ (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:1744:25) at WebElement.click (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:1845:17) at actionFn (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\built\element.js:99:44) at Array.map (native) at C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\built\element.js:406:46 at ManagedPromise.invokeCallback_ (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1379:14) at TaskQueue.execute_ (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2913:14) at TaskQueue.executeNext_ (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2896:21) at asyncRun (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2775:27)Error at ElementArrayFinder.applyAction_ (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\built\element.js:403:27) at ElementArrayFinder._this.(anonymous function) [as click] (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\built\element.js:101:30) at ElementFinder.(anonymous function) [as click] (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\built\element.js:740:22) at Object. (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\example\loginpost.js:40:51) at C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:94:23 at new ManagedPromise (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1082:7) at controlFlowExecute (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:80:18) at TaskQueue.execute_ (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2913:14) at TaskQueue.executeNext_ (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2896:21) at asyncRun (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2820:25) From: Task: Run it("on dashboard") in control flow at Object. (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:79:14) From asynchronous test: Error at Suite. (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\example\loginpost.js:16:2) at Object. (C:\Users\Telekha\AppData\Roaming\npm\node_modules\protractor\example\loginpost.js:1:1) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12)

2 specs, 1 failure.

and my code to upload the image:

element( by.css('[ng-click="imagePost()"]') ).click();   
browser.sleep(3000);
element(by.model("files")).click();
var path = require('path'); var fileToUpload = 'Desktop:/mdkg.jpg';
var absolutePath = path.resolve(fileToUpload); 
var button = element(by.css('[ngf-select]')); 
button.click(); 
var input = element(by.css('input[type="file"]'));     
input.sendKeys(absolutePath);
element(by.buttonText('Post Image')).click();
Sudharsan Selvaraj
  • 4,792
  • 3
  • 14
  • 22
Ajay
  • 307
  • 4
  • 14
  • 1
    First of all format your code. Element you're trying to interact with is behind something else, that's why protractor can't click desired element. – FCin Nov 24 '16 at 12:26
  • updated the format. @FCin – Ajay Nov 24 '16 at 12:30
  • pause your test(`browser.pause()`) before sending file and see if something is blocking your view. – FCin Nov 24 '16 at 12:33
  • Starting debugger agent. Debugger listening on [::]:5858 ControlFlow::2282 | TaskQueue::186 | | (pending) Task::188 | | | TaskQueue::1394 | | | | (pending) Task::1396 | | | | | TaskQueue::1399 | | | | | | (blocked) Task::1441<> @FCin – Ajay Nov 24 '16 at 12:37
  • See the browser, not console. Just look at it and see if some html element is blocking protractor from sending message. The other option is that it tries to send it before the control is loaded. You can try to `browser.sleep(5000)` before sending just to test if this is the case – FCin Nov 24 '16 at 12:41
  • Failed: unknown error: Element is not clickable at point (736, 187). Other element would receive the click: (Session info: chrome=54.0.2840.99) (Driver info: chromedriver=2.25.426923 ,platform=Windows NT 10.0.14393 x86_64).this error getting @FCin – Ajay Nov 24 '16 at 12:49
  • There are several workaround to make this work.have a look at http://stackoverflow.com/questions/37809915/element-not-visible-error-not-able-to-click-an-element – Sudharsan Selvaraj Nov 24 '16 at 13:32
  • Thanks for the info @SudharsanSelvaraj , and i worked with all the scenarios ,but still getting that. – Ajay Nov 24 '16 at 13:37
  • if you use `browser.executeScript("arguments[0].click()", button.getWebElement())` , then definitely it won't throw the same error. – Sudharsan Selvaraj Nov 24 '16 at 13:45
  • Could you please also share the Page DOM? – Vishal Aggarwal Nov 24 '16 at 21:09
  • when i click on image icon it's opening a modal and modal contains two buttons like upload and post.when i click on upload it's navigating local system there we can pick the image and we can post.protractor navigating to local system and it is unable to pick the image.@VishalAggarwal – Ajay Nov 25 '16 at 04:54

2 Answers2

0

You can use wait element to be clickable

 var EC = protractor.ExpectedConditions;
 var element = element(by.xpath([xpath_locator]));
browser.wait(EC.elementToBeClickable(element(by.xpath([xpath_locator]))), 30000).then(function () {
                element.click();
});

You can select element by any locator in this case I'm selecting it by xpath, and

radio_head
  • 1,306
  • 4
  • 13
  • 28
Sanja Paskova
  • 1,110
  • 8
  • 15
0

Include this statement:

browser.driver.manage().window().maximize(); into

onPrepare() method of protractor.conf.js file like given below.

onPrepare () {
 browser.driver.manage().window().maximize();
}
Raj Kumar
  • 758
  • 6
  • 12