我確定,這個問題可以由經驗豐富的Java開發人員快速回答。但是由於我對Java並不熟悉,我不知道如何從Java中獲取Selenium的@Config部分。如果我可以有一個配置文件或類,我可以將數據(瀏覽器,網站等)和測試文件放在一起,那將是最佳選擇。
下面是測試文件的例子:
Selenium Java - 如何外包@Config並從外部類調用測試?
package com.example_test.selenium;
import io.ddavison.conductor.Browser;
import io.ddavison.conductor.Config;
import io.ddavison.conductor.Locomotive;
import org.junit.Test;
@Config(
browser = Browser.CHROME,
url = "http://example.com"
)
public class test_a_Home extends Locomotive {
@Test
public void testifExists() {
validatePresent(site_a_Home.EL_NEWCUSTOMERBANNER);
}
}
現在我想有一個名爲tests.java在那裏我可以稱之爲「test_a_Home」 - 函數一個單獨的文件。如果我嘗試它只是
package com.example_test.selenium;
public class tests {
test_a_Home test = new test_a_Home();
test.testifExists();
}
我收到的錯誤,即「testifExists()」不能得到解決。
我嘗試將public void testifExists()
更改爲public int testifExists()
,並試圖在class tests
中用int res = test.testifExists();
調用它,但這也不起作用,因爲我收到錯誤java.lang.Exception: Method testNewCustomersBannerExists() should be void
。
如果有人能幫助我,我會非常高興。如果您需要更多信息,請隨時提及。謝謝。
謝謝,它的工作。 –
很高興聽到!繼續並通過點擊綠色選中標記將此答案標記爲「已接受」,如果您覺得我配得上它,請繼續並上傳 – sircapsalot