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.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. * @since 8.0.6
  27. */
  28. public long getRowCount() {
  29. Long res = (Long) getCommandExecutor()
  30. .executeScript("return arguments[0].getRowCount()", this);
  31. if (res == null) {
  32. throw new IllegalStateException("getRowCount returned null");
  33. }
  34. return res.longValue();
  35. }
  36. /**
  37. * Gets the total number of columns in the layout.
  38. *
  39. * @return the number of columns in the layout
  40. * @since 8.0.6
  41. */
  42. public long getColumnCount() {
  43. Long res = (Long) getCommandExecutor()
  44. .executeScript("return arguments[0].getColumnCount()", this);
  45. if (res == null) {
  46. throw new IllegalStateException("getColumnCount returned null");
  47. }
  48. return res.longValue();
  49. }
  50. /**
  51. * Gets the cell element at the given position.
  52. *
  53. * @param row
  54. * the row coordinate
  55. * @param column
  56. * the column coordinate
  57. * @return the cell element at the given position
  58. * @throws NoSuchElementException
  59. * if no cell was found at the given position
  60. * @since 8.0.6
  61. */
  62. public WebElement getCell(int row, int column) {
  63. WebElement res = (WebElement) getCommandExecutor().executeScript(
  64. "return arguments[0].getCell(" + row + "," + column + ")",
  65. this);
  66. if (res == null) {
  67. throw new NoSuchElementException(
  68. "No cell found at " + row + "," + column);
  69. }
  70. return res;
  71. }
  72. }