我有两个.java文件,一个文件(StockWatchlistElements.java)我声明了页面的所有元素,第二个文件(Example.java)我使用了该元素。
StockWatchlistElements.java
Internal Server Error: /register/
Traceback (most recent call last):
File "/home/marcel/.virtualenvs/django/lib/python3.7/site-packages /django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/marcel/.virtualenvs/django/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/marcel/.virtualenvs/django/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/marcel/website/users/views.py", line 45, in register
form = user(request.POST)
Example.java
public static WebElement lnkaStockWatchlist(WebDriver driver) {
try {
element = driver.findElements(By.xpath("//*[@id=\"dnn_ctr769_StockWatchList_pnlContent\"]/table/tbody/tr"));
} catch (Exception e) {
throw (e);
}
return element;
}
答案 0 :(得分:2)
将您的方法定义从WebElement
更改为List<WebElement>
,例如:
public static List<WebElement> lnkStockWatchlist(WebDriver driver) {
List<WebElement> element = new ArrayList<>();
try {
element = driver.findElements(By.xpath("//*[@id=\"dnn_ctr769_StockWatchList_pnlContent\"]/table/tbody/tr"));
} catch (Exception e) {
throw (e);
}
return element;
}