2017-10-31 8 views
2

내가는 아래의 HTML 콘텐츠를 가지고 :로봇 프레임 워크에서 AND 조건을 사용하는 방법은 무엇입니까?

<input type="radio" name="radioButton" value="on" id="radio1" tabindex="0"> 
<input type="radio" name="radioButton" value="on" id="radio2" tabindex="0"> 
<input type="radio" name="radioButton" value="on" id="radio3" tabindex="0"> 

참조 : 나는 현재 내 시나리오와 가장 관련이 아니에요 위 link.But에 언급 된 논리를 시도하고 How to use OR condition for Keywords in Robot Framework?

.

유형, 이름 및 ID 또는 클래스를 사용하여 라디오 버튼을 가져 와서 선택하고 싶습니다.

선택 라디오 버튼의 경우 // 입력 및 // 입력 [이름 = "라디오 버튼"]와 // 입력 [[유형 = "라디오"@] @id :

나는 다음과 같은 것을 달성하고자하는 = "radio2"]

답변

2

if 문은 필요하지 않습니다. 모든 조건을 단일 xpath에 넣기 만하면됩니다. 예 :

select radio button //input[@type='radio' and @name='radioButton' and @id='radio2'] 

id가 고유 한 경우 모두 필요하지는 않습니다. 당신은 다음

WebDriver driver = new FirefoxDriver(); //it can be any driver, not specifically firefox 

WebElement radioButton = driver.findElement(By.xpath("//input[@type='radio' and @name='radioButton' and @id='radio2']"); 
radioButton.click(); 

위의 기능은 요소에 대한보고를 클릭합니다 할 수

select radio button //input[@id='radio2'] 
0

: ID가 고유 한 경우에 당신은 같은 것을 사용할 수 있습니다. 그리고 @Bryan이 말했듯이, ID가 고유하다면 ID로만 요소를 찾을 수 있습니다.

WebDriver driver = new FirefoxDriver(); //it can be any driver, not specifically firefox 
WebElement radioButton = driver.findElement(By.id("@id='radio2']"); 
radioButton.click();