Can you please tell me how to click onclick via WebDriver? thank you in advance.

<span class="surf_ckick" onclick="start_test('tests_view?id=067eb917f6aabc129964f767d155f47e', '2801'); this.style.textDecoration='line-through'; this.style.color='#FF3800'; ">Исто.рический </span> 

    1 answer 1

    Very simple, click on the element:

     driver.findElement(By.className("surf_ckick")).click(); 

    When you click, the onclick event will occur and the corresponding start_test function will be start_test

    • thanks for your reply. When you click on this button, the page should open, but it does not open, what should I do? - as1andrey1 1:09
    • @ as1andrey1 Check the browser console for JS errors and verify the start_test function - tCode
    • As if the button is pressed, and the page does not open - as1andrey1
    • @ as1andrey1 I advise you to read learn.javascript.ru/introduction-browser-events - tCode
    • maybe the page opens in the second tab? - as1andrey1