Python Forum
Field with dynamic id not found at playback
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Field with dynamic id not found at playback
#1
I record a short sequence with Selenium IDE on a SAP gui:

1   self.driver.find_element(By.ID, "M0:U:::5:53").click()
2   self.driver.switch_to.default_content()
3   self.driver.switch_to.frame(2)
4   self.driver.find_element(By.ID, "M1:U:1::0:1-title").click()
5   self.driver.find_element(By.ID, "tbl102[1,2]_c").click()
6   self.driver.find_element(By.ID, "tbl102[1,2]_c").send_keys("123")
7   self.driver.find_element(By.ID, "tbl102[1,3]_c").click()
8   self.driver.find_element(By.ID, "tbl102[1,3]_c").send_keys("456")
at playback time everything works fine until row 5
rows 2-3 change to a new frame
row 4 in the new frame clicks just fine a title
rows 5-8 don't find the field because the id tbl102[1, 2] is dynamic where the xxx change every time (tblxxx[1, 2])
ok, so I implement id with wildcards. But nothing seems to work:

loaded = len(browser.find_elements_by_xpath('//*[@id]'))
loaded = len(browser.find_elements_by_xpath('//*[contains(@id, "tbl") AND contains(@id, "_c")]')) (This one is error syntax)

browser.find_elements_by_id('*[1,3]_c')
browser.find_elements_by_id('*[*')

browser.find_elements_by_xpath('//*[contains(@id, "[1,3]_c")]').click()
browser.find_elements_by_xpath('//*[contains(@id, "[1,3]_c")]').send_keys("242")

browser.find_element(By.xpath("//*[ends-with(@id, ‘[1,3]_c’)]").click()
browser.find_element(By.xpath("//*[ends-with(@id, ‘[1,3]_c’)]").send_keys("242")

browser.find_elements(By.Id("tbl*"))

browser.find_elements(By.xpath("//[starts-with(@id, ‘tbl’)]");
browser.find_elements(By.xpath("//[contains(@id, ‘tbl’)]");
browser.find_elements(By.xpath("//*[ends-with(@id, ‘_c’)]");
None of the above gives hit. So I print out all elements in the frame with some kind of id:

el = browser.find_elements_by_xpath('//*[contains(@id, "t")]')
for i in el:
    if len(i.text) > 0:
        print(">" + i.text + "<")
And to my surprise there are no elements containing "tbl" AT ALL!!

The code above I execute right after row 4 in my first code at the top which works fine and proves that I am in the right frame.

Anyone has an idea of what is happening?

However after rows 5-8 have been executed and py/selenium has not been able to write to the field I do an inspect (FF).
The field has id=tbl327[1,3]_c which should be able to be detected by one of the wildcard id above. But NOT.

In row 4 py/selenium clicks on 'Select Ranges' folder that is in the same frame as the fields in rows 5-8
In my book that proves that I am in the right frame. Or not? what do you guys think?

Will appreciate all ideas leading to solve the issue.

[Image: 75GLdvrz]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How can I found how many numbers are there in a Collatz Sequence that I found? cananb 2 2,533 Nov-23-2020, 05:15 PM
Last Post: cananb
  Bug ? when dataclass field name == field type Cyril 0 1,546 Oct-22-2020, 03:26 AM
Last Post: Cyril
  start and stop omxlayer playback dezmob 2 4,758 Jan-27-2020, 09:43 AM
Last Post: dezmob
  No module named Playback ABadLab 1 2,079 Dec-19-2018, 03:44 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020