셀레니움 사이트 자동화 테스트이다.
사이트 주소는 다음과 같다.
https://www.tutorialspoint.com/selenium/selenium_automation_practice.htm
드롭박스를 선택하는 방법은 아래와 같은데...AsSelect의 매소드로 인덱스, 값과 옵션등 여러가지가 더 있으니 연구해보길 바란다.
Sel.FindElementByCss("select[name='continents']").AsSelect.SelectByText "Asia"
더보기
Sub Sel_Exp()
Dim strUrl$
strUrl = "https://www.tutorialspoint.com/selenium/selenium_automation_practice.htm"
' Sel.AddArgument "--headless" '= 헤드리스모드
Sel.Start "chrome" '= 크롬으로 진행
Sel.Get strUrl '= Url 이동
Sel.FindElementByCss("input[name='firstname']").SendKeys "Haja" '= First name
Sel.FindElementByCss("input[name='lastname']").SendKeys "ExaNam" '= Last name
Sel.FindElementByCss("input[value='Male']").Click '= Sex
Sel.FindElementByCss("input[value='5']").Click '= Years of Experience
Sel.FindElementByCss("tbody > tr:nth-child(5) > td:nth-child(2) > input[type=text]").SendKeys Format(Now, "yyyy-mm-dd")
'= Date
Sel.FindElementByCss("input[value='Automation Tester']").Click '= Profession
Sel.FindElementByCss("input[type='file']").ClickDouble '= Profile Picture
Application.Wait Now + TimeValue("0:00:02") '= 2초 대기
SendKeys "C:\Users\DRP_MAIN\Pictures\방탄소년단.jpg" & "{enter}" '= 파일경로
Application.Wait Now + TimeValue("0:00:02") '= 2초 대기
SendKeys "C:\Users\DRP_MAIN\Pictures\방탄소년단.jpg" & "{enter}" '= 파일경로
Sel.FindElementByCss("input[value='Selenium Webdriver']").Click '= Flavours of Selenium
Sel.FindElementByCss("select[name='continents']").AsSelect.SelectByText "Asia" '= Continents
Sel.FindElementByCss("select[name='selenium_commands']").AsSelect.SelectByText "WebElement Commands"
'= Selenium Commands
Sel.FindElementByCss("button[name='submit']").Submit '= Button click
' Sel.SwitchToAlert.Accept '= 경고창 확인
Sel.SwitchToAlert.Dismiss '= 경고창 취소
MsgBox "완료하였습니다."
End Sub
'VBA > 엑사남_심화방' 카테고리의 다른 글
[심화방] VBA_심화_100제 #14 [ 셀레니움 네이버항공 조회] (0) | 2023.04.01 |
---|---|
[심화방] VBA_심화_100제 #13 [ 셀레니움 네이버 로그인] (0) | 2023.03.20 |
[심화방] VBA_심화_100제 #11 [ 셀레니움 Astable] (0) | 2023.03.13 |
[심화방] VBA_심화_100제 #10 [ 네이버부동산] (2) | 2023.02.06 |
[심화방] VBA_심화_100제 #9 [ JsonConverter : 환율불러오기 ] (0) | 2023.01.20 |
댓글