Dustin N.
Dustin N.

Reputation: 795

CSS Selector without an attribute - Selenium Webdriver - Java

How would I select the class "form-control" (which is a dropdown) for the "th" that equals "Pay From" using the CSS selector in Java?

<table class="table">
<tbody>
<tr>
<th>Pay From</th>
<td>
<select class="form-control col-sm-2 ng-pristine ng-invalid ng-invalid-required ng-touched" ng-model="payment.selectedPaymentMethod" ng-options="paymentMethod as paymentMethod.text for paymentMethod in payment.paymentMethods track by paymentMethod.paymentMethodId" name="accountType" required="">

I know you can do something similar to the following for 'nested' objects:

(By.cssSelector("table[class='table'] > select[class^='form-control']"));

but how do I utilize the "th" that doesn't have an attribute?

Upvotes: 1

Views: 281

Answers (1)

MikeJRamsey56
MikeJRamsey56

Reputation: 2829

(By.cssSelector("table[class='table'] > tr:nth-child(1) > th:nth-child(1)"));

Upvotes: 2

Related Questions