-2

I'm trying to do an automation web test with Selenium Python. Where I could read the xpath of an WebElement and/or the method I want to do with it for example send_keys() from an Excel file.

I managed to make the code works, but problem is the method click() doesn't work. Nothing happens.

 try:
                ActualValue = dv.find_element_by_xpath(f1)
                if f3 != '':
                    getattr(ActualValue, f2)(f3)
                else:
                    getattr(ActualValue, f2)

In the above code, I splited the strings from Excel file to 3 parts, f1 is the path to get to the WebElement, f2 is the Method/ Attribute, f3 is the Parameter.

The code works fine for other methods, just the click() one doesn't do anything.

1 Answers1

0

click() is a method with parameter self. You need to send this parameter as well

getattr(ActualValue, 'click')()
Guy
  • 46,488
  • 10
  • 44
  • 88