All Downloads are FREE. Search and download functionalities are using the official Maven repository.

co.verisoft.fw.utils.locators.TdBy Maven / Gradle / Ivy

There is a newer version: 2.3.9
Show newest version
package co.verisoft.fw.utils.locators;

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import org.openqa.selenium.By;

/**
 * 

* A set of methods to be used when looking for fields value in a table. This * mechanism used to locate elements within a document using a single lookup. It * converts row number and column number into search objects and returns * {@link By By} object with results. *

* * * @author Nir Gallner * @since 0.1 * * @see org.openqa.selenium.support.pagefactory.ByAll * @see AnyBy * @see ElementBy * @see InputBy * @see AllBy * @see NotBy */ public final class TdBy { private TdBy() { } /** * Looks for a cell value with rowNumber and columnNumber.
* For example:
* with the following table:
* * * * * * * * * * * * * * * * * * * * * * * * *
MonthSavings
Sum$180
January$100
February$80
*

The code {@code WebElement element = driver.findElement(TdBy.cellLocation(1,0));}
* will return the value "January" * @param rowNumber * row number to look for. First row is 0 * @param columnNumber * col number to look for. First col is 0 * @return {@link By } object with the locators * ready in it */ public static By cellLocation(int rowNumber, int columnNumber) { return By.xpath(String.format("//tbody//tr[%d]/td[%d]", rowNumber, columnNumber+1)); } /** * Looks for a header valuewith a specific columnNumber.
* For example:
* with the following table:
* * * * * * * * * * * * * * * * * * * * * * * * *
MonthSavings
Sum$180
January$100
February$80
* The code {@code WebElement element = driver.findElement(TdBy.tableHeader(0));}
* will return the value "Month" * * @param columnNumber * col number to look for. First col is 0. * @return {@link By } object with the locators * ready in it */ public static By tableHeader(int columnNumber) { return By.xpath(String.format("//tr/th[%d]", columnNumber+1)); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy