#*# .#* *~ _site/ */src/META-INF/ */src/main/java/META-INF/ bin/ target/ .classpath .project .DS_Store .settings/ .springBeans *.iml *.iws *.ipr .idea/ code/ cargo-installs/ atlassian-ide-plugin.xml deploy/
2020년 1월 16일 목요일
.gitignore 내용
Selenium implicitly wait & explicitly wait
[implicitly wait]
해당 페이지에 속한 element가 모두 로딩될 때 까지 기다리는 방식
syntax
example
[explicitly wait]
특정 element가 나타날 때 까지 기다려주는 방식
syntax
exmaple
해당 페이지에 속한 element가 모두 로딩될 때 까지 기다리는 방식
syntax
driver.manage().timeouts().implicitlyWait(TimeOut, TimeUnit.SECONDS);
example
driver = new ChromeDriver(co); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.manage().window().maximize(); return driver;
[explicitly wait]
특정 element가 나타날 때 까지 기다려주는 방식
syntax
WebDriverWait wait = new WebDriverWait(WebDriverReference, TimeOut);
exmaple
driver = new ChromeDriver(); WebDriverWait wait = new WebDriverWait(driver, 20); .... WebElement element; element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(",,,"))); element.click();
2020년 1월 14일 화요일
HttpStatusCode 체크
import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.HttpClientBuilder; HttpClient client = HttpClientBuilder.create().build(); HttpResponse response = client.execute(new HttpGet(URL)); int statusCode = response.getStatusLine().getStatusCode(); logger.debug("StatusCode: {}", statusCode);
2019년 12월 5일 목요일
Selenium implicitly-wait and explicitly-wait
implicitly-wait : 브라우져 전체 요소가 로드될 때 까지 기다린다.
explicitly-wait : 특정 요소가 로드될 때 까지 기다린다.
implicitly wait
Explicitly wate
Fluent wait
explicitly-wait : 특정 요소가 로드될 때 까지 기다린다.
implicitly wait
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | import java.util.concurrent.TimeUnit; import org.openqa.selenium.*; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; public class WaitTest { private WebDriver driver; private String baseUrl; private WebElement element; @BeforeMethod public void setUp() throws Exception { driver = new FirefoxDriver(); baseUrl = "http://www.google.com"; driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); } @Test public void testUntitled() throws Exception { driver.get(baseUrl); element = driver.findElement(By.id("lst-ib")); element.sendKeys("Selenium WebDriver Interview questions"); element.sendKeys(Keys.RETURN); List<WebElement> list = driver.findElements(By.className("_Rm")); System.out.println(list.size()); } @AfterMethod public void tearDown() throws Exception { driver.quit(); } } |
Explicitly wate
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | 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.firefox.FirefoxDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; public class ExpectedConditionExample { // created reference variable for WebDriver WebDriver driver; @BeforeMethod public void setup() throws InterruptedException { // initializing driver variable using FirefoxDriver driver=new FirefoxDriver(); // launching gmail.com on the browser driver.get("https://gmail.com"); // maximized the browser window driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); } @Test public void test() throws InterruptedException { // saving the GUI element reference into a "element" variable of WebElement type WebElement element = driver.findElement(By.id("Email")); // entering username element.sendKeys("dummy@gmail.com"); element.sendKeys(Keys.RETURN); // entering password driver.findElement(By.id("Passwd")).sendKeys("password"); // clicking signin button driver.findElement(By.id("signIn")).click(); // explicit wait - to wait for the compose button to be click-able WebDriverWait wait = new WebDriverWait(driver,30); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[contains(text(),'COMPOSE')]"))); // click on the compose button as soon as the "compose" button is visible driver.findElement(By.xpath("//div[contains(text(),'COMPOSE')]")).click(); } @AfterMethod public void teardown() { // closes all the browser windows opened by web driver driver.quit(); } } |
Fluent wait
1 2 3 4 5 6 7 8 9 | Wait wait = new FluentWait(WebDriver reference) .withTimeout(timeout, SECONDS) .pollingEvery(timeout, SECONDS) .ignoring(Exception.class); WebElement foo = wait.until(new Function<WebDriver, WebElement>() { public WebElement applyy(WebDriver driver) { return driver.findElement(By.id("foo")); }}); |
2019년 12월 2일 월요일
Jenkins 관련 내용
Windows Jenkins settings.xml 파일 위치
=> C:\Windows\System32\config\systemprofile\.m2
외부 리포트 파일의 css 적용되지 않을 경우
=> jenkins.xml에 "-Dhudson.model.DirectoryBrowserSupport.CSP=" 추가하기
=> C:\Windows\System32\config\systemprofile\.m2
외부 리포트 파일의 css 적용되지 않을 경우
=> jenkins.xml에 "-Dhudson.model.DirectoryBrowserSupport.CSP=" 추가하기
2019년 11월 28일 목요일
REST API의 개념
REST의 정의
"REpresentational State Transfer"로서 자원(resource)을 이름(표현)으로 구분하여 해당 자원의 상태(정보)를 주고 받는 모든 것을 의미한다.
자원(resource)의 표현(representation)은
자원(resource) : 해당 소프트웨어가 관리하는 모든 것(문서, 그림, 데이터 등등)
표현(representation) : 자원을 표현하기 위한 이름(회원 정보가 자원이라면 'member'를 자원의 표현으로 정하는 것)
상태(정보) 전달은 데이터가 요청되는 시점에 자원의 상태(정보)를 전달한다.
Json 혹은 XML로 데이터를 주고 받는다.
REST API는??
API(Application Programming Interface) : 데이터와 기능의 집합을 제공하여 컴퓨터 프로그램 간 상호작용을 촉진하며, 서로 정보를 교환 가능하도록 하는 것을 말한다.
그래서 REST API는 REST 기반으로 서비스 API를 구현한 것이다.
REST API 설계 규칙
- 슬래시 구분자( / ) 는 계층 관계를 나타내는데 사용한다.
예: http://sample.com/home/login - URI 마지막 문자로 슬래시( / )를 포함하지 않는다.
예: httpL//sample.com/home/login/ ( X ) - 하이픈( - ) 은 URI 가독성을 높이는데 사용한다.
- 밑줄( _ ) 은 URI에 사용하지 않는다.
- URI 경로에는 소문자
- 파일확장자는 URI에 포함하지 않는다.
그러면 RESTful API는 뭐지???
REST가 위에서 설명한 것과 같다면 RESTful은 REST라는 아키텍쳐를 구현하는 웹 서비스를 나타내기 위해 사용되는 용어이다.
'REST API'를 제공하는 웹서비스를 'RESTful'하다고 할 수 있다. 즉, REST 원리를 따르는 시스템은 RESTful이란 용어로 지칭한다.
HTTP Method
HTTP Method
|
전송 형태
|
설명
|
|---|---|---|
| GET |
GET [request-uri]?query_string HTTP/1.1
Host:[Hostname] 혹은 [IP] | 요청받은 URI의 정보를 검색하여 응답 |
| POST |
POST [request-uri] HTTP/1.1
Host:[Hostname] 혹은 [IP] Content-Lenght:[Length in Bytes] Content-Type:[Content Type] [데이터] | 요청된 자원을 생성한다. |
| PUT |
PUT [request-uri] HTTP/1.1
Host:[Hostname] 혹은 [IP] Content-Lenght:[Length in Bytes] Content-Type:[Content Type] [데이터] | 요청된 자원을 수정(UPDATE)한다. |
| DELETE |
DELETE [request-uri] HTTP/1.1
Host:[Hostname] 혹은 [IP] | 요청된 자원을 삭제할 것을 요청 |
| PATCH |
PATCH [request-uri] HTTP/1.1
Host:[Hostname] 혹은 [IP] Content-Lenght:[Length in Bytes] Content-Type:[Content Type] [데이터] |
PUT과 유사하게 요청된 자원을 수정(UPDATE)할 때 사용.
PUT의 경우 자원 전체를 갱신하는 의미지만, PATCH는 해당 자원의 일부를 교체하는 의미로 사용 |
Content-Type
해당 개체에 포함되는 미디어 타입 정보를 말하며 응답 내에 있는 Content-Type 헤더는 클라이언트에게 반환된 컨텐츠의 컨텐츠 유형이 실제로 무엇인지를 알려준다.
컨텐츠의 타입(MIME 미디어 타입)과 문자 인코딩 방식(EUC-KR, UTF-8등)을 지정한다.
문법
Content-Type: text/html; charset=utf-8Content-Type: multipart/form-data; boundary=somthing |
HTTP code
응답 대역
응답 코드
설명
성공 200 OK
201 Created
PUT 메소드에 의해 원격지 서버에 파일 생성됨
203 서버가 클라이언트 요구 중 일부만 전송
204 No content
요구한 데이터를 변경된 타 URL에 요청함 / Redirect된 경우
클라이언트
요청 에러
400 Bad Request
사용자의 잘못된 요청을 처리할 수 없음
401 인증이 필요한 페이지를 요청한 경우
403 접근 금지
404 Not found
요청한 페이지 없음
405 허용되지 않는 http method 사용함
408 요청 시간 초과
410 영구적으로 사용 금지
412 전체 조건 실패
414 요청URL길이가 긴 경우
서버에러 500 내부 서버 오류
501 웹 서버가 처리할 수 없음
503 서비스 제공 불가
504 Gateway timeout
게이트웨이 시간 초과
505 해당 http 버전 지원되지 않음
응답 대역
|
응답 코드
|
설명
|
|---|---|---|
| 성공 | 200 | OK |
| 201 | Created PUT 메소드에 의해 원격지 서버에 파일 생성됨 | |
| 203 | 서버가 클라이언트 요구 중 일부만 전송 | |
| 204 | No content 요구한 데이터를 변경된 타 URL에 요청함 / Redirect된 경우 | |
클라이언트
요청 에러 | 400 | Bad Request 사용자의 잘못된 요청을 처리할 수 없음 |
| 401 | 인증이 필요한 페이지를 요청한 경우 | |
| 403 | 접근 금지 | |
| 404 | Not found 요청한 페이지 없음 | |
| 405 | 허용되지 않는 http method 사용함 | |
| 408 | 요청 시간 초과 | |
| 410 | 영구적으로 사용 금지 | |
| 412 | 전체 조건 실패 | |
| 414 | 요청URL길이가 긴 경우 | |
| 서버에러 | 500 | 내부 서버 오류 |
| 501 | 웹 서버가 처리할 수 없음 | |
| 503 | 서비스 제공 불가 | |
| 504 | Gateway timeout 게이트웨이 시간 초과 | |
| 505 | 해당 http 버전 지원되지 않음 |
URL과 URI의 의미
- URL(Uniform Resource Locator) : 통합 자원 지시자
- 예를 들어 http://test.com/work/test.pdf 는 test.com 서버에서 work 폴더 안의 test.pdf를 요청하는 URL을 의미한다.
- URI(Unitform Resource Identifier) : 통합 자원 식별자
- 프로토콜 + : + // + 호스트이름 + 주소 → http://test.com
- 자원에 접근하기 위해 사용되는 절차
- 어떤 자원을 가지고 있는 특정한 컴퓨터
- 컴퓨터 상의 유니크한 자원의 이름(파일명)
- URN(Uniform Resource Name) : 리소스의 위치와 상관없이 리소스의 이름값을 이용하여 접근하는 방식
| URI | |
|---|---|
| URN | URL |
| test.com/test.html | https://test.com/test.html |
| test2.com/image.png | ftp://test2.com.file.pdf |
URI >= URL, URN
피드 구독하기:
글 (Atom)