차트 데이터를 자동화하는 중입니다. 데이터가 어떻게 표시되는지 아래에 나와 있습니다.selgium webdriver를 사용하여 svg 경로 요소를 클릭 할 수 없습니다.
<g style="cursor:pointer;" clip-path="url(#highcharts-2)" transform="translate(62,10) scale(1 1)" class="highcharts-markers highcharts-series-0 highcharts-tracker">
<path d="M 811 367.23566666666665 L 816 372.23566666666665 811 377.23566666666665 806 372.23566666666665 Z" fill="#18abc9"></path>
<path d="M 731 400.91344444444445 L 736 405.91344444444445 731 410.91344444444445 726 405.91344444444445 Z" fill="#18abc9"></path>
<path d="M 651 386.432 L 656 391.432 651 396.432 646 391.432 Z" fill="#18abc9"></path>
<path d="M 570 390.61766666666665 L 575 395.61766666666665 570 400.61766666666665 565 395.61766666666665 Z" fill="#18abc9"></path>
<path d="M 490 381.09166666666664 L 495 386.09166666666664 490 391.09166666666664 485 386.09166666666664 Z" fill="#18abc9">
</path><path d="M 410 334.905 L 415 339.905 410 344.905 405 339.905 Z" fill="#18abc9"></path></g>
첫 번째 경로 요소를 클릭하기 위해 다음 셀렌 코드를 작성했습니다.
List<WebElement> a = driver.findElements(By.xpath("(//*[name()='svg']//*[name()='path' and contains(@fill, '#090')])[1]"));
Actions actionBuilder = new Actions(driver);
actionBuilder.click(a.get(0)).build().perform();
목록 a
에는 수신 된 web 요소가 하나뿐입니다. 클릭 할 때 프로그램에서 오류가 발생합니다.
org.openqa.selenium.WebDriverException : 요소 (904, 556.86669921875)에서 클릭 할 수 없습니다. 다른 요소는 다음과 같은 클릭을 받게됩니다.
<path d="M 801 341.00352 L 806 346.00352 801 351.00352 796 346.00352 Z" fill="#090"></path>
오류에서 제공 한 경로는 제공된 DOM과 완전히 동일하지 않습니다.
'JavascriptExecutor'를 사용하여'((JavascriptExecutor) 드라이버) .executeScript ("arguments [0] .click()", a.get (0));'그리고 알려주세요 –
@Saurabh Gaur 그것은 org.openqa.selenium.WebDriverException : arguments [0] .click이 함수가 아닙니다. – ChanChow
이 인수는 [0] .cli ck()이어야하며'()'이 누락되었습니다. 수정하십시오. –