Содержимое таблицы не загружается с помощью селена Webdriver. Он отображает только заголовки таблицы, но не содержимое.
Я успешно вошел в свое приложение, но на главном экране есть таблица с определенным проектом в списке, а при использовании селена содержимое таблицы не загружается.
Селеновые банки: 2,53
Версия Mozilla Firefox: 46.0
Использовал браузер Google Chrome для того же, но он тоже не работал.
Когда я закрываю браузер (который открыл селен) и снова открываю его вручную, он работает нормально. Но когда селен открывает его и переходит на домашнюю страницу, данные таблицы не загружаются.
<div class="project-list-bg" _ngcontent-c1="">
<div class="col s12 project-container" _ngcontent-c1="">
<main _ngcontent-c1="">
<div class="col s12 search-block" _ngcontent-c1="">
<div class="search-wrapper" _ngcontent-c1="">
<label _ngcontent-c1="">Search: </label>
<div class="card" _ngcontent-c1="">
<input class="ng-untouched ng-pristine ng-valid" type="text" _ngcontent-c1="" name="search">
</div>
</div>
</div>
<table id="myTable" class="bordered centered " _ngcontent-c1="">
<thead _ngcontent-c1="">
<tr _ngcontent-c1="">
<th class="grey-text text-darken-1" width="10%" _ngcontent-c1="">
Project ID
<i class="material-icons" _ngcontent-c1="">keyboard_arrow_down</i>
</th>
<th class="grey-text text-darken-1" width="17%" _ngcontent-c1="">
Project Name
<i class="material-icons" _ngcontent-c1="">keyboard_arrow_down</i>
</th>
<th class="grey-text text-darken-1" _ngcontent-c1="" style="width: 12%;">
Date Completed
<i class="material-icons" _ngcontent-c1="">keyboard_arrow_down</i>
</th>
<th class="grey-text text-darken-1" width="10%" _ngcontent-c1="" style="background-image: none; ">
# of Runs
<i class="material-icons" _ngcontent-c1="">keyboard_arrow_down</i>
</th>
<th class="grey-text text-darken-1" width="10%" _ngcontent-c1="" style="background-image: none; ">
Status
<i class="material-icons" _ngcontent-c1="">keyboard_arrow_down</i>
</th>
<th class="grey-text text-darken-1" width="16%" _ngcontent-c1="" style="background-image: none; ">
Project Description
<i class="material-icons" _ngcontent-c1="">keyboard_arrow_down</i>
</th>
<th width="12%" _ngcontent-c1="" style="background-image: none; "></th>
</tr>
</thead>
<tbody _ngcontent-c1="">
</table>
<div class="pagination right-align" _ngcontent-c1="">
<pagination-controls _ngcontent-c1="">
<pagination-template>
<ul class="ngx-pagination" role="navigation" aria-label="Pagination">
</pagination-template>
</pagination-controls>
</div>
<div class="row" _ngcontent-c1="">
<div class="col s6 add-btn2 left-align" _ngcontent-c1="">
<a _ngcontent-c1="" routerlink="/project-information" href="/project-information">
<button class="btn next-btn p-btn" _ngcontent-c1=""> Add Project</button>
</a>
</div>
<div class="col s6 right-align" _ngcontent-c1="">
<ul id="myPager" class="pagination pager" _ngcontent-c1=""></ul>
</div>
</div>
</main>
</div>
</div>
------------ Selenium Code --------------------------------- -
package projectListingScreen;
import org.testng.annotations.Test;
import ObjectRepository.HomescreenObject;
import ObjectRepository.PageObject;
import loginScreen.LoginPage;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeTest;
public class HomeScreen extends LoginPage {
public WebDriver driver;
@Test
public void f() {
WebDriverWait wait=new WebDriverWait(driver, 20);
WebElement addprojectbutton;
addprojectbutton = wait.until(ExpectedConditions.elementToBeClickable(By.xpath( "html/body/app-root/app-home/div/div/main/div[3]/div[1]/a/button")));
addprojectbutton.click();
}
Мне нужно щелкнуть по этому элементу <button>
, но если таблица (HTML таблицы, которую вы можете найти в комментариях) не загружается должным образом, эта кнопка перемещается вверх, и селен не может найти эту кнопку и, в свою очередь, дает ноль исключение указателя.