3

I am working on PhantomJS with Java for one of my project. I am looking for some help in working with PhantomJS in following scenario.

Scenario:

Step-1: Mouse hover on tab/link then 2 sub-links will display

Step-2: Click on 2nd sub-link (This element is not visible if width is less than 992)

Here in Step-2, I am failing due to page is not displaying the element. I have tried following ways to resolve:

  1. Added wait statement before clicking (Explicit wait -> wait until element clickable)

Note: Script getting failed in this step due to element is not clickable.

  1. Set the custom window size (1920 X 1080)

Note: Here my query is when I used driver.window.maximize(), I am getting window size as "1366 X 768". So I am not sure whether it will work if I set the window size as "1920 X 1080".

Please share your experiences or idea's to resolve this issue. Your help/suggestions are very helpful to me

NOTE: I am facing this issue only PhanjomJS browser only in remaining all browsers are working fine

4
  • It should work. You can check by yourself. Try to make a screen-shot and check its dimension.
    – Alexey R.
    Oct 5, 2017 at 12:00
  • @AlexeyR. I tried it but still getting same error. So I am not sure whether it is resizing or not
    – QAMember
    Oct 5, 2017 at 12:06
  • So waht is your screen-shot showing? Is the element really ontside of the viewport (to the left or to the right or above or below)? Or it presents on the screen-shot?
    – Alexey R.
    Oct 5, 2017 at 12:37
  • @AlexeyR. Screenshot shows that elements disturbed due to the size and showing like a mobile view
    – QAMember
    Oct 6, 2017 at 6:40

1 Answer 1

0

Given some WebDriver, one can modify the dimensions of the window-size of the WebDriver leveraging a method comparable to the one below.

public static void setWindowSize(WebDriver driver, int width, int height) {
      Dimension dm = new Dimension(width, height);
      //Setting the current window to that dimension
      driver.manage().window().setSize(dm);
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.