나는 testNG에서 작동하도록 아래 코드를 테스트하고 싶다. testNG.The 시나리오는 때로는 요소 n을 식별 할 수있는 코드이기도하므로 모든 로케이터를 전달하는 코드를 작성하기로 결정한다. 이제까지 그것 (그것의 부호는이다)에 그것을 클릭 할 것이다 찾아 낸다.엘리먼트에서 clcick에 여러 개의 인수를 전달하는 방법은 무엇입니까? TestNG
public static void Click(WebDriver d,String id,String xpath,String css, String linktext,String name,String Partial_link_Text)
{
System.out.println("For click method");
try{d.findElement(By.id(id)).click();}
catch (Exception e){System.out.print("ID not found, ");}
try{d.findElement(By.xpath(xpath)).click();}
catch (Exception e){System.out.print("xpath not found, ");}
try{d.findElement(By.cssSelector(css)).click();}
catch (Exception e){System.out.print("css not found, ");}
try{d.findElement(By.linkText(linktext)).click();}
catch (Exception e){System.out.print("linktext not found, ");}
try{d.findElement(By.name(name)).click();}
catch (Exception e){System.out.print("name not found, ");}
try{d.findElement(By.partialLinkText(Partial_link_Text)).click();}
catch (Exception e){System.out.print("Partial linktext not found, ");}
System.out.println("");
}
위의 메서드는 locator가 작동하지 않는 경우에도 testNG로 전달됩니다. 왜냐하면 try/catch는 testNg에서 예외를 잡기 때문에 오류가 없으므로 testNG가 테스트 케이스를 통과합니다. 그래서 누구든지 pl 제안을 줄 수 또는 요소를 찾을 수없는 경우 테스트 케이스 실패하게 논리 "OR"사용하여 같은 코드를 제공 할 수 있습니다. 그 이유는 당신이 기다리고되지 않을
, 수
시나리오는 때때로하지 요소 N 을 식별 할 내 코드는 때로는 수 :
설명으로
친절 셀레늄 대기를 사용할 수 있습니까? – DolphinJava