0

I have tried several ways to make a button clickable using Selenium in Python and it seems none of my tries were good enough.

This is how the HTML looks like:

< class="divModulesItems" style="margin-left:0px; margin-top:0px; margin-right:0px; margin-bottom:0px;" onclick="location.href='CSIQTHourEntry.aspx'"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="-370 248.3 100 100" style="enable-background:new -370 248.3 100 100;" xml:space="preserve" focusable="false">

<br Enter <br hours 

This is the latest I tried, by using onclick method:

EnterHours = HoursEntryPortal.find_element(By.XPATH("//*[ contains(text(), 'hours')]"));

Also, by using the above code, I get the following error:

TypeError: 'str' object is not callable

Any idea how could I make this button clickable? Maybe my sintax is not correct or I omit something.

  • I don't see `Manager_wp1078203230_wp724786216_linkContainer` in the provided HTML – cruisepandey Apr 22 '22 at 16:45
  • What is `ONCLICK` ? Does your framework use it's own customized locator? – cruisepandey Apr 22 '22 at 16:47
  • I just realized I've put a test variant here. This is what I wanted to say: ``` EnterHoursElement = HoursEntryPortal.find_element(By.XPATH(//*[@id="Manager_wp1078203230_wp724786216_LinkWidgetSpanTitle"])) ``` Also tried this way: ` #EnterHours = HoursEntryPortal.find_element(By.XPATH("//*[ contains(text(), 'hours')]")); #EnterHours = HoursEntryPortal.find_element(By.XPATH("//*[ IsDisplayed() = ‘hours’ ]")); Using the text() method I get the following error: TypeError: 'str' object is not callable – Bancila Alexandru Apr 22 '22 at 16:57
  • Instead of the handcrafted HTML, update the question with the text based actual HTML. – undetected Selenium Apr 22 '22 at 20:02
  • Does this answer your question? [python selenium click on button](https://stackoverflow.com/questions/21350605/python-selenium-click-on-button) – Alias Cartellano Apr 22 '22 at 21:43

0 Answers0