0

I'm working with the application, which I have made test in my old tool (HP QTP), now I need convert it to selenium(python webdriver), I have issue with specific part, during the test flow I receive image with the value, (data is static only for testing), so I know what value I should send for response. In HP QTP I solved it by 'if conditional' and loop (VB code below):

For Each elem As HtmlElement In WebBrowser1.Document.GetElementsByTagName("img")
     If elem.GetAttribute("src") = "http://URL/image_1.png" Then
     WebBrowser1.Document.GetElementById("response").SetAttribute("value", "70")
     End If
     If elem.GetAttribute("src") = "http://URL/image_2.png" Then
     WebBrowser1.Document.GetElementById("response").SetAttribute("value", "80")
     End If

I don't know how it should looks in python. I didn't found equivalent function for "elem.GetAttribute("")" in Python. Unfortunately I have lack experience with python so I'm looking for solution or hints for this issue.

1 Answers1

1

There is a get_attribute method available in python API. You need to find the element and be able to perform same action you are doing in vb. Consult this and here is an example how to do it.

Community
  • 1
  • 1
Saifur
  • 16,081
  • 6
  • 49
  • 73