 image source: [pixabay](https://pixabay.com/) --- 지난 시간에 잠시 언급했던 TestNG annotation 중 `@Test` annotation의 속성을 좀 더 알아본다. `@Test` annotation은 테스트하려는 하나의 케이스를 표현한다. 이를테면 로그인, 글쓰기 등을 하나의 케이스로 볼 수 있겠다. 이런 케이스 메소드 위에 `@Test`를 넣어 케이스를 쉽게 관리할 수 있고 속성을 추가하여 부가적인 기능도 추가할 수 있다. 아래 예제를 한번 보자. 1. 총 세 개의 케이스를 지정한다. 2. `enabled` 속성으로 해당 케이스를 실행할지 안 할지 설정한다. 디폴트 값은 true이고 false일 경우 이 케이스를 건너뛴다. `@Test`앞에 주석(//)만 추가하면 동일 기능인데 무슨 차이가 있는지, 왜 사용해야 하는지는 잘 모르겠다. 3. `description`은 말 그대로 이 케이스의 설명이고, 상세하게 기입할수록 좋을 것 같다. 4. `timeOut`는 이 케이스가 실행되는 기대 시간이다. 시간을 초과하면 Exception이 발생하고 리포트에 Fail로 기록된다. UI 자동화에서는 큰 효과가 있을지 의문이지만, 속도를 중요시하는 API 테스트일 경우 상당한 효과가 있을 것으로 보인다. ``` @Test(enabled = false, description = "글 목록을 불러온다.") public void CASE_01_GetPosts() { .... Some Action ... } @Test(timeOut = 60000, description = "로그인 한다.") public void CASE_02_Login() { .... Some Action ... } @Test(description = "스팀잇에 글 쓰기 한다. ") public void CASE_03_Write() { .... Some Action ... } ``` 위 예제에서 메소드 명에 번호가 추가되어 있는데 이는 TestNG가 테스트를 수행할 때 순서를 정하기 위함이다. TestNG는 메소드 name ascending 순으로 테스트를 수행한다. 하지만 메소드에 꼭 번호를 매겨야 하는 건 아니다. 이 또한 속성으로 대신할 수 있는데 priority 속성으로 순서를 정할 수 있다. ``` @Test(priority = 3, description = "스팀잇에 글 쓰기 한다. ") public void Write() { .... Some Action ... } ``` 이 외에도 `dependsOnMethods`, `groups`, `dataProvider`,`dataProviderClass` 등 다양한 속성이 존재하는데 나중에 필요할 때 차차 다루도록 한다. ``` package com.steem.webatuo; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import java.util.List; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import io.github.bonigarcia.wdm.WebDriverManager; public class Steemit { WebDriver driver; @BeforeClass public void SetUp() { WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(); driver.get("STEEMIT URL"); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS); } @Test(enabled = false, description = "글 목록을 불러온다.") public void CASE_01_GetPosts() { List<WebElement> list = driver.findElements(By.xpath("//div[@id='posts_list']/ul/li")); assertTrue(!list.isEmpty(), "글 목록이 있는지 확인"); for (WebElement post : list) { String title = post.findElement(By.xpath("descendant::h2/a")).getText(); String author = post.findElement(By.xpath("descendant::span[@class='user__name']")).getText(); System.out.println(author + "님의 글: " + title); } } @Test(timeOut = 60000, description = "로그인 한다.") public void CASE_02_Login() throws InterruptedException { // Click the login button driver.findElement(By.linkText("로그인")).click(); // type id driver.findElement(By.name("username")).sendKeys("june0620"); // type pw and submit WebElement pw = driver.findElement(By.name("password")); assertNotNull(pw, "비밀번호 태그가 노출되는지 확인"); pw.sendKeys(Password.getPw()); pw.submit(); Thread.sleep(5000); } @Test(description = "스팀잇에 글 쓰기 한다. ") public void CASE_03_Write() throws InterruptedException { // Click the write Button List<WebElement> writeBtns = driver.findElements(By.xpath("//a[@href='/submit.html']")); assertEquals(writeBtns.size(), 1, "글쓰기 버튼이 노출되는지 확인"); for (WebElement writeBtn : writeBtns) { if (writeBtn.isDisplayed()) { writeBtn.click(); Thread.sleep(2000); // type Text and Keys WebElement editor = driver.findElement(By.xpath("//textarea[@name='body']")); String keys = Keys.chord(Keys.LEFT_SHIFT, Keys.ENTER); editor.sendKeys("hello!! world", keys, "hello!!! STEEMIT", Keys.ENTER, "안녕, 스팀잇", Keys.ENTER, "你好!似提姆"); break; } } Thread.sleep(5000); } @AfterClass public void tearDownClass() { driver.quit(); } } ``` . . . . [Cookie 😅] Seleniun java lib version: 3.141.59 java version: 13.0.1
author | june0620 |
---|---|
permlink | java-web-automation-selenium-with-testng-3-test-annotation-kr |
category | hive-101145 |
json_metadata | {"tags":["hive-101145","kr","mini","steemstem","sct-kr","sct-freeboard","zzan","java","coding","sct","partiko"],"image":["https://files.steempeak.com/file/steempeak/june0620/DKldjbG3-reds-java-house-1591357_1280.jpg"],"links":["https://pixabay.com/"],"app":"partiko","format":"markdown","canonical_url":"https://www.steemcoinpan.com/@june0620/java-web-automation-selenium-with-testng-3-test-annotation-kr"} |
created | 2020-03-14 12:44:18 |
last_update | 2020-03-15 12:15:36 |
depth | 0 |
children | 7 |
last_payout | 2020-03-21 12:44:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 7.715 HBD |
curator_payout_value | 6.402 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 4,632 |
author_reputation | 118,592,211,436,406 |
root_title | "[JAVA #14] [Web Automation #14] Selenium With TestNG #3 @Test annotation [KR]" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 96,346,280 |
net_rshares | 36,168,263,305,728 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
gerber | 0 | 92,567,849,358 | 4% | ||
daan | 0 | 170,337,166,307 | 8% | ||
exyle | 0 | 675,313,631,439 | 7% | ||
magicmonk | 0 | 1,724,741,818,773 | 100% | ||
ffcrossculture | 0 | 69,060,926,232 | 15% | ||
tumutanzi | 0 | 1,802,802,578 | 50% | ||
holoz0r | 0 | 1,337,609,519 | 1.75% | ||
ramires | 0 | 6,893,266,507 | 25% | ||
coldhair | 0 | 884,323,292 | 50% | ||
ucukertz | 0 | 715,553,187 | 25% | ||
msg768 | 0 | 806,998,138 | 5% | ||
mys | 0 | 4,647,686,159 | 2.52% | ||
jhy2246 | 0 | 27,491,763,253 | 10% | ||
virus707 | 0 | 3,285,889,619,842 | 19% | ||
ew-and-patterns | 0 | 168,094,269,115 | 8% | ||
ricko66 | 0 | 70,586,595,286 | 100% | ||
techken | 0 | 20,568,674 | 0.28% | ||
whd | 0 | 2,233,476,014 | 2% | ||
khaiyoui | 0 | 1,256,428,744,749 | 30% | ||
cryptopie | 0 | 233,359,698,103 | 46% | ||
christianity101 | 0 | 137,876,308 | 40% | ||
ilovemylife | 0 | 787,461,839,402 | 35% | ||
tookta | 0 | 159,601,610,144 | 100% | ||
dream.trip | 0 | 2,681,206,293 | 46% | ||
azulear | 0 | 8,543,473,277 | 100% | ||
thaiteam | 0 | 124,291,909,449 | 80% | ||
tipu | 0 | 3,479,616,136,044 | 5% | ||
kimzwarch | 0 | 8,242,611,314 | 4% | ||
seapy | 0 | 8,185,476,776 | 60% | ||
accelerator | 0 | 65,504,910,461 | 4% | ||
june0620 | 0 | 1,168,629,469,547 | 100% | ||
roleerob | 0 | 1,169,790,266 | 0.4% | ||
xiaoshancun | 0 | 22,495,811,325 | 100% | ||
lindalex | 0 | 580,290,767 | 50% | ||
blockbrothers | 0 | 98,660,804,644 | 3.5% | ||
rudyardcatling | 0 | 843,143,908 | 100% | ||
cnbuddy | 0 | 1,773,490,400,479 | 100% | ||
banjjakism | 0 | 5,444,224,453 | 9.5% | ||
itchyfeetdonica | 0 | 267,551,962,441 | 50% | ||
gamezine | 0 | 4,271,661,155 | 25% | ||
stupid | 0 | 748,841,662 | 40% | ||
mehta | 0 | 145,021,403,708 | 40% | ||
suhunter | 0 | 953,167,543 | 50% | ||
udabeu | 0 | 13,109,173,450 | 30% | ||
marsswim | 0 | 103,365,951,309 | 51% | ||
cadawg | 0 | 10,028,604,041 | 2.8% | ||
maikuraki | 0 | 5,521,398,696 | 19% | ||
fego | 0 | 4,461,326,025 | 3.5% | ||
beleg | 0 | 839,438,540 | 2% | ||
bestboom | 0 | 32,571,246,233 | 4% | ||
abrockman | 0 | 4,601,617,940 | 1.2% | ||
lucky2015 | 0 | 355,749,815,468 | 100% | ||
gghite | 0 | 379,268,911,782 | 60% | ||
jaydih | 0 | 419,927,477,532 | 11% | ||
andrewma | 0 | 12,468,829,949 | 50% | ||
kimseun | 0 | 70,679,509,834 | 11% | ||
meedo | 0 | 73,124,924 | 100% | ||
ravenkim | 0 | 3,063,451,353 | 100% | ||
pilimili | 0 | 440,372,997 | 95% | ||
freegon | 0 | 184,184,368,608 | 100% | ||
kanadaramagi123 | 0 | 48,113,332,916 | 11% | ||
loveecho | 0 | 86,176,884,690 | 11% | ||
wanggang | 0 | 150,489,721,805 | 20% | ||
mightypanda | 0 | 1,727,365,237 | 3.5% | ||
pagliozzo | 0 | 18,075,824,951 | 20% | ||
angelslake | 0 | 18,303,401,531 | 11% | ||
teamvn | 0 | 19,308,997,017 | 38.72% | ||
harkar | 0 | 94,502,394,912 | 20% | ||
dlike | 0 | 161,947,282,444 | 2.45% | ||
triptolemus | 0 | 15,093,056,535 | 4% | ||
lupafilotaxia | 0 | 43,374,563,918 | 50% | ||
changxiu | 0 | 5,009,317,588 | 50% | ||
sj-jeong | 0 | 579,392,629,240 | 11% | ||
wondumyungga | 0 | 39,177,117,489 | 11% | ||
seo70 | 0 | 36,583,981,400 | 70% | ||
djusti | 0 | 1,037,056,501,409 | 100% | ||
talkative-bk | 0 | 455,330,364,805 | 11% | ||
nineteensixteen | 0 | 679,137,157,906 | 100% | ||
wherein | 0 | 2,283,073,122,798 | 48% | ||
sindong | 0 | 628,805,141,665 | 80% | ||
steemfriends | 0 | 4,479,276,431 | 100% | ||
swiftbot | 0 | 578,313,745 | 5% | ||
cyberrn | 0 | 760,108,527,698 | 18% | ||
permaculturedude | 0 | 744,288,415 | 2% | ||
sklara | 0 | 55,226,941,516 | 30% | ||
happybelly | 0 | 6,044,603,525,245 | 15% | ||
tina3721 | 0 | 4,823,176,418 | 50% | ||
andyhsia | 0 | 7,239,914,797 | 100% | ||
minigame | 0 | 2,649,600,116,362 | 8% | ||
whatdidshewear | 0 | 90,036,116,525 | 11% | ||
mustard-seed | 0 | 30,204,683,333 | 11% | ||
mytron | 0 | 1,339,921,581 | 100% | ||
steemindian | 0 | 726,759,747 | 3.5% | ||
fsm-liquid | 0 | 18,547,899,181 | 7% | ||
triplea.cur | 0 | 4,126,661,447 | 9.5% | ||
jayplay.aaa | 0 | 1,210,700,723 | 19% | ||
zzan.hmy | 0 | 79,511,455,495 | 2% | ||
triplea.bot | 0 | 2,099,130,373 | 7% | ||
mini.sct | 0 | 2,324,910,936 | 40% | ||
leo.voter | 0 | 25,649,050,626 | 0.76% | ||
cn-sct | 0 | 1,895,830,277 | 2% | ||
freddio.sport | 0 | 42,317,978,012 | 15% | ||
sct1004 | 0 | 481,566,992 | 20% | ||
freegon.sct | 0 | 9,586,993,480 | 100% | ||
mapxv | 0 | 30,386,364,148 | 3.6% | ||
tokenindustry | 0 | 3,609,872,057 | 80% | ||
sct.krwp | 0 | 163,668,524,315 | 0.24% | ||
leo.syndication | 0 | 1,922,078,829 | 4% | ||
one.life | 0 | 35,090,120,402 | 3.99% | ||
maxuva | 0 | 2,063,130,114 | 4% | ||
maxuvb | 0 | 2,060,214,582 | 4% | ||
maxuvc | 0 | 1,917,659,709 | 4% | ||
maxuvd | 0 | 1,914,796,835 | 4% | ||
maxuve | 0 | 19,146,929,833 | 4% | ||
bcm | 0 | 308,339,758,057 | 1% | ||
sqljoker | 0 | 30,887,705 | 2% | ||
sct.curator | 0 | 18,468,825,054 | 22.22% | ||
therealyme | 0 | 5,026,897,554 | 5.6% | ||
jaykayw | 0 | 24,522,680,003 | 11% | ||
triple.aaa | 0 | 656,691,618,793 | 19% | ||
cnbuddy-reward | 0 | 1,059,166,043,712 | 100% | ||
real3earch | 0 | 8,654,000,399 | 100% | ||
unpopular | 0 | 37,354,072,922 | 40% | ||
florianopolis | 0 | 1,451,305,445 | 1% | ||
tonystarkalive | 0 | 0 | 2% | ||
reward.tier2 | 0 | 1,911,822,102 | 100% | ||
bilpcoinpower | 0 | 272,595,336 | 10% | ||
bcm.zzan | 0 | 0 | 1.2% | ||
steemcityrewards | 0 | 18,754,201,639 | 2.4% |
***But the end of all things has drawn near.*** Therefore be sober-minded and be sober unto prayers.(1 Peter 4:7) ## Question from the Bible, *What does the Bible Say About Tithing?* Watch the Video below to know the Answer... ***(Sorry for sending this comment. We are not looking for our self profit, our intentions is to preach the words of God in any means possible.)*** https://youtu.be/49OGYhhXXKY Comment what you understand of our Youtube Video to receive our full votes. We have 30,000 #SteemPower. It's our little way to **Thank you, our beloved friend.** Check our [Discord Chat](https://discord.gg/vzHFNd6) Join our Official Community: https://steemit.com/created/hive-182074
author | florianopolis |
---|---|
permlink | on3ubytib1j |
category | hive-101145 |
json_metadata | "" |
created | 2020-03-14 12:52:33 |
last_update | 2020-03-14 12:52:33 |
depth | 1 |
children | 0 |
last_payout | 2020-03-21 12:52:33 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 692 |
author_reputation | -5,988,767,749,052 |
root_title | "[JAVA #14] [Web Automation #14] Selenium With TestNG #3 @Test annotation [KR]" |
beneficiaries | [] |
max_accepted_payout | 10,000.000 HBD |
percent_hbd | 100 |
post_id | 96,346,426 |
net_rshares | -24,557,712,871 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
mack-bot | 0 | -26,004,414,118 | -0.25% | ||
florianopolis | 0 | 1,446,701,247 | 1% |
你好鸭,june0620! @yanhan给您叫了一份外卖! **巧克力蛋糕** <br>  吃饱了吗?跟我猜拳吧! **石头,剪刀,布~** 如果您对我的服务满意,请不要吝啬您的点赞~
author | teamcn-shop |
---|---|
permlink | wherein-1584190106924 |
category | hive-101145 |
json_metadata | "{"app":"teamcn-shop bot/1.0"}" |
created | 2020-03-14 12:48:42 |
last_update | 2020-03-14 12:48:42 |
depth | 1 |
children | 0 |
last_payout | 2020-03-21 12:48:42 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 256 |
author_reputation | 11,393,746,055,281 |
root_title | "[JAVA #14] [Web Automation #14] Selenium With TestNG #3 @Test annotation [KR]" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 96,346,346 |
net_rshares | 0 |
@tipu curate !shop 来自于 [WhereIn Android] (http://www.wherein.io)
author | yanhan |
---|---|
permlink | wherein-1584190106924 |
category | hive-101145 |
json_metadata | "" |
created | 2020-03-14 12:48:30 |
last_update | 2020-03-14 12:48:30 |
depth | 1 |
children | 4 |
last_payout | 2020-03-21 12:48:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 65 |
author_reputation | 323,731,670,852,703 |
root_title | "[JAVA #14] [Web Automation #14] Selenium With TestNG #3 @Test annotation [KR]" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 96,346,343 |
net_rshares | 0 |
晚上好啊😀😎
author | june0620 | ||||||
---|---|---|---|---|---|---|---|
permlink | re-yanhan-2020314t215011618z | ||||||
category | hive-101145 | ||||||
json_metadata | {"tags":["esteem"],"app":"esteem/2.2.4-mobile","format":"markdown+html","community":"hive-125125"} | ||||||
created | 2020-03-14 12:50:15 | ||||||
last_update | 2020-03-14 12:50:15 | ||||||
depth | 2 | ||||||
children | 2 | ||||||
last_payout | 2020-03-21 12:50:15 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 0.000 HBD | ||||||
curator_payout_value | 0.000 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 6 | ||||||
author_reputation | 118,592,211,436,406 | ||||||
root_title | "[JAVA #14] [Web Automation #14] Selenium With TestNG #3 @Test annotation [KR]" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 96,346,375 | ||||||
net_rshares | 0 |
我在这呢🤭 Posted using [Partiko Android](https://partiko.app/referral/annepink)
author | annepink |
---|---|
permlink | annepink-re-june0620-re-yanhan-2020314t215011618z-20200314t125131417z |
category | hive-101145 |
json_metadata | {"app":"partiko","client":"android"} |
created | 2020-03-14 12:51:30 |
last_update | 2020-03-14 12:51:30 |
depth | 3 |
children | 1 |
last_payout | 2020-03-21 12:51:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 76 |
author_reputation | 1,030,853,853,537,931 |
root_title | "[JAVA #14] [Web Automation #14] Selenium With TestNG #3 @Test annotation [KR]" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 96,346,408 |
net_rshares | 0 |
<a href="https://tipu.online/curator?yanhan" target="_blank">Upvoted 👌</a> (Mana: 5/15 - <a href="https://steempeak.com/steem/@tipu/tipu-curate-project-update-recharging-curation-mana" target="_blank">need recharge</a>?)
author | tipu |
---|---|
permlink | re-wherein-1584190106924-20200314t124845 |
category | hive-101145 |
json_metadata | "" |
created | 2020-03-14 12:48:42 |
last_update | 2020-03-14 12:48:42 |
depth | 2 |
children | 0 |
last_payout | 2020-03-21 12:48:42 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 229 |
author_reputation | 55,914,556,170,175 |
root_title | "[JAVA #14] [Web Automation #14] Selenium With TestNG #3 @Test annotation [KR]" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 96,346,350 |
net_rshares | 0 |