You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GridLayoutElement.java 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.testbench.elements;
  17. import org.openqa.selenium.NoSuchElementException;
  18. import org.openqa.selenium.WebElement;
  19. import com.vaadin.testbench.elementsbase.ServerClass;
  20. @ServerClass("com.vaadin.ui.GridLayout")
  21. public class GridLayoutElement extends AbstractLayoutElement {
  22. /**
  23. * Gets the total number of rows in the layout.
  24. *
  25. * @return the number of rows in the layout,
  26. */
  27. public long getRowCount() {
  28. Long res = (Long) getCommandExecutor()
  29. .executeScript("return arguments[0].getRowCount()", this);
  30. if (res == null) {
  31. throw new IllegalStateException("getRowCount returned null");
  32. }
  33. return res.longValue();
  34. }
  35. /**
  36. * Gets the total number of columns in the layout.
  37. *
  38. * @return the number of columns in the layout,
  39. */
  40. public long getColumnCount() {
  41. Long res = (Long) getCommandExecutor()
  42. .executeScript("return arguments[0].getColumnCount()", this);
  43. if (res == null) {
  44. throw new IllegalStateException("getColumnCount returned null");
  45. }
  46. return res.longValue();
  47. }
  48. /**
  49. * Gets the cell element at the given position.
  50. *
  51. * @param row
  52. * the row coordinate
  53. * @param column
  54. * the column coordinate
  55. * @return the cell element at the given position
  56. * @throws NoSuchElementException
  57. * if no cell was found at the given position
  58. */
  59. public WebElement getCell(int row, int column) {
  60. WebElement res = (WebElement) getCommandExecutor().executeScript(
  61. "return arguments[0].getCell(" + row + "," + column + ")",
  62. this);
  63. if (res == null) {
  64. throw new NoSuchElementException(
  65. "No cell found at " + row + "," + column);
  66. }
  67. return res;
  68. }
  69. }