2014-11-28 5 views
0

I가 I이 (가) 로그인의 버튼을 식별하는 XPath는 //a[@href='javascript:setAction('ValidateUser')']을 사용하고요소를 식별하는 방법 클래스 이름이 같은 경우?

<a class="dboxheader" href="javascript:setAction('ValidateUser')">Sign&nbsp;In</a> 

<a class="dboxheader" href="javascript:setAction('Reset')">Reset</a> 

2 개 버튼 로그인 절차 및 재설정 .. .. 버튼 오류 아래 점점 :

org.openqa.selenium.InvalidSelectorException: The given selector //a[@href='javascript:setAction('ValidateUser')'] is either invalid or does not result in a WebElement. The following error occurred: 
InvalidSelectorError: Unable to locate an element with the xpath expression //a[@href='javascript:setAction('ValidateUser')'] because of the following error: 
SyntaxError: The expression is not a legal expression. 

어떻게이 문제를 해결하기 위해 ???

답변

0

작은 따옴표 안에 작은 따옴표가 있습니다.

select='//a[@href="javascript:setAction(&apos;ValidateUser&apos;)"]' 
0

이 상대 XPath의의 아름다움이다 : 그것은 셀레늄에서 작동하지만, 또한 다음과 같은 방법으로 모두의 Xalan과 색슨 작업 방법을 알고하지 마십시오. 계급은 같지만 여러 방법으로 쉽게 식별 할 수 있습니다. // a는 [포함 "요소를 찾을 수 없습니다 : {"방법 ":"XPath는 ","선택 "

//a[contains(text(),'Sign&nbsp;In')] 
//a[contains(text(),'Reset')] 
+0

이하이 작동하지 않습니다 .. org.openqa.selenium.NoSuchElementException을

시도 (text(), 'Sign   In')] "} 명령 기간 또는 시간 초과 : 15 밀리 초 – ChanGan

+0

이 웹 요소를 클릭하기 전에 아래 코드를 사용하십시오. assertTrue (driver.getPageSource(). contains ("Sign   In")); 오류 메시지를 알려주십시오. –

+0

boolean b = driver.getPageSource(). contains ("Sign   In"); System.out.println (b); 결과 : 거짓 – ChanGan

관련 문제