-1

I am working on a project where the application is deployed on a kiosk machine after development and QA. Since i have to test it on my local machine, the default size (i.e.100%) of the application in the browser moves out of the window without any scroll bars, hence it becomes difficult to trace the element. Therefore, i am reducing the size from 100% to 50% through script.

browser.get("url");
browser.driver.executeScript("document.body.style.zoom='50%'");
browser.findElement(by.xpath("WebElement")).click();

Error: Failed: unknown error: Element

Ramii
  • 111
  • 1
  • 11
  • This doesn't seems like full error message. Can you add the whole error message. – demouser123 May 02 '18 at 12:44
  • Also, you don't use this syntax in Protractor - `findElement` – demouser123 May 02 '18 at 12:44
  • Full Error Message: Failures: 1) Message: [31m Failed: unknown error: Element is not clickable at point (536, 490). Other element would receive the click: (Session info: chrome=65.0.3325.181) (Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 10.0.15063 x86_64)[0m – Ramii May 03 '18 at 06:32

1 Answers1

1

In Protractor, the syntax comes in this format

element(by.xpath("valid_xpath"))

browser.get("url");
browser.driver.executeScript("document.body.style.zoom='50%'");
element(by.xpath("xpath_here")).click()

Edit 1: Since OP provided the correct error message, the error seems that due to the change in resolution the element might not be visible or be overlapped with a span or div element, which is the reason why the click event is going to another co-ordinates.

Please refer to this SO post, where this error has been discussed in detail along with the remedy steps.

demouser123
  • 4,108
  • 9
  • 50
  • 82
  • It does not work. Error: Failed: unknown error. if i comment this "browser.driver.executeScript("document.body.style.zoom='50%'");" and execute then it identifies the element but it is of no use since requirement is to keep zoom at 50% – Ramii May 03 '18 at 06:19
  • Since you're zooming it to a different resolution, most probably the element is not in the view or the xpath changed. See how the DOM changes due to the resolution change and you'll figure it out. – demouser123 May 03 '18 at 06:32
  • i verified, xpath does not change, it remains the same. i have highlighted the web button at runtime through script using xpath for both 100% and 50% zoom, both the time buttton gets highlighted, but is not clickable at 50% – Ramii May 03 '18 at 07:47