0

One of button does not appear on UI if zoom level of my browser is 100%, so once I zoom-in using the below code, that particular button appears on UI

driver.execute_script("document.body.style.zoom='80%'")

But action on that particular button does not happen even though button appears on UI in zoom-in state, instead I get this error message

{WebDriverException}Message: unknown error: Element is not clickable at point (891, 568). Other element would receive the click: (Session info: chrome=58.0.3029.110) (Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 6.1.7601 SP1 x86)

I do not get issue on my local machine, since that particular button appears on UI when zoom level of browser is 100%, it works well as I don't have to zoom-in.

But since I have to work on virtual box which I connect remotely using client machine, there I get this UI issue. Since virtual box screen appears inside my client machine's screen, its height gets reduced and that particular button disappears from UI at the bottom.

So need to zoom-in in order to perform this action and again reset zoom level to 100%. Am I doing anything wrong here or is there any other way to resolve such issue?

Edit: Attaching screenshot enter image description here

9
  • can you try to scroll element instead of zoom out JavascriptExecutor jse = (JavascriptExecutor)driver; jse.executeScript("window.scrollBy(0,250)", ""); let me know if facing same issue Commented May 24, 2017 at 7:31
  • 1
    change resolution of your client machine Commented May 24, 2017 at 7:53
  • @ShoaibAkhtar why are you using both Java & Python tags? What language is your client written in? Can you also consider posting the snippet of code that has the issues? It's pretty hard to debug you issue as it stands. Also a.f.a.i.k, Webdriver is not bound by the display port when doing actions like .click() so there might be another issue why this is not working. Commented May 24, 2017 at 8:13
  • @TrimantraSoftwareSolution I have attached screenshot now in question, even with scrollbar the button does not appear Commented May 24, 2017 at 9:26
  • @san1deep2set3hi I have set maximum resolution, i.e 1400*796 for virtual box and 1400*900 for my client machine, reducing it will show too much big fonts. Also since virtual box screen appears inside client machine, so its height gets reduced and causing this issue Commented May 24, 2017 at 9:29

3 Answers 3

1

You can simulate scroll using ActionChains class

from selenium.webdriver.common.action_chains import ActionChains

element = driver.find_element_by_...
ActionChains(driver).move_to_element(element).perform()
element.click()
Sign up to request clarification or add additional context in comments.

Comments

0

For test automation if we have to deal with remote machines(e.g. in case of Sauce labs) it is always beneficial to take screen resolution seriously.

In today's world of responsive websites where we need to change browser window size quite often this requirement is becoming more effective.

In sauce labs we change resolution of client machine programatically using following

capabilities.setCapability("screenResolution", "1920x1080");

For different setup, we might need to follow steps as mentioned in comments by @ShoaibAkhtar above.

Comments

0

I had the same issue. Driver should normally scroll to element on every Click, and it does, but it scrolls just so element just barely visible.

So it can sometimes be covered by another element, while driver thinks element is visible, and then theres an exception.

I found an nice workaround here: selenium scroll element into (center of) view

Center page so element is in middle of page:

In C#:

var js = d as IJavaScriptExecutor;

String scrollElementIntoMiddle = "var viewPortHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);"
                                                    + "var elementTop = arguments[0].getBoundingClientRect().top;"
                                                    + "window.scrollBy(0, elementTop-(viewPortHeight/2));";

js.ExecuteScript(scrollElementIntoMiddle, element);

element.Click();

I tried zoom out at first, but at least with Chrome, Selenium cant work at all when zoomed out, so that didnt work.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.