Created
February 6, 2014 15:43
-
-
Save ssmiech/8846686 to your computer and use it in GitHub Desktop.
Clicking <table> column based on another columnt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table> | |
<tr> | |
<th>Name</th> | |
<th>Mobile</th> | |
<th>No Introducer</th> | |
<th>Created On</th> | |
<th>Status</th> | |
<th>Action</th> | |
</tr> | |
<tr> | |
<td>Adill</td><td>6666655555</td><td>Nitesh</td><td>05-02-2014</td><td>Pending For Approval</td><td><input>Button</input></td> | |
</tr> | |
<tr> | |
<td>Adill</td><td>6666644444</td><td>Nitesh</td><td>05-02-2014</td><td>Pending For Approval</td><td><input>Button</input></td> | |
</tr> | |
<tr> | |
<td>Adill</td><td>6666633333</td><td>Nitesh</td><td>05-02-2014</td><td>Pending For Approval</td><td><input>Button</input></td> | |
</tr> | |
</table> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package selenium; | |
import java.sql.Driver; | |
import java.util.List; | |
import java.util.concurrent.TimeUnit; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.support.ui.ExpectedConditions; | |
import org.openqa.selenium.support.ui.Wait; | |
import org.openqa.selenium.support.ui.WebDriverWait; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.JavascriptExecutor; | |
import org.openqa.selenium.firefox.FirefoxDriver;; | |
public class test { | |
private static WebDriver driver; | |
public static void main(String[] args) { | |
driver = new FirefoxDriver(); | |
driver.get("http://localhost"); | |
getRowText(); | |
} | |
public static String getRowText(){ | |
String text = null; | |
String column = null; | |
WebElement table = driver.findElement(By.tagName("table")); | |
List<WebElement> allrows = table.findElements(By.tagName("tr")); | |
for(WebElement row : allrows){ | |
List<WebElement> columns = null; | |
String number = null; | |
columns = row.findElements(By.tagName("td")); | |
if (columns.size() > 0) { | |
number = columns.get(1).getText(); | |
System.out.println(number); | |
if(number.equals("6666633333")) { | |
System.out.println("aaaa"); | |
columns.get(5).findElement(By.tagName("input")).click(); | |
} | |
} | |
} | |
return text; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment