Search code examples
c#seleniumxpathautomationwebautomation

Selenium web automation with Xpath targeting button clicks, is there a more performant method?


I wrote a C# interface to go through the automated clicking of certain buttons on a job board to send resumes and cover letters. My Xpath is like //button[@title=1-Click Apply]

They must've changed their xpath to the button, because after 6 months, it doesnt perform at all. And when it was, it was taking 3 seconds per page to gather a list of Buttons and to then iterate each button's click. It took about 2 minutes to send 10000 resumes, but I have a queue of people who want to use the service, and I can't send resumes quick enough. Is there a better way to re-write this to make it much more performant or to have an xpath that works? The xpath I have now should target this button, but its not.

<button class="job_tool job_apply default" 
data-interview="0" data-oneclick="" data-contact="" data-job="0" 
 data-href="https://www.ziprecruiter.com/clk/horizontal-integration-f0b9b05c-sr-software-engineer-tester-
15821-f7703d07?clk=VliBhk7_SO">1-Click Apply</button>

Solution

  • Your text "1-Click Apply" does not belongs to attribute "title". Try change your xpath to this: //button[text()="1-Click Apply"]