Python Forum
Find Dynamic Input Element Class Problem
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find Dynamic Input Element Class Problem
#1
Hi All

I'm new to this group and trust me I have searched high and low to get this answer but now having to resort to asking for help.

I need to clear the content of an input box its class=masterCustomDropDown the problem there is 7 of these on the web page which is OracleBI. All are the identical class and every attribute is the same. The only differentiating part is the ID which is dynamic. The id for the input box i need to clear is 'saw_#####_#_1' the # can be any length the problem is there is other ID's on the page that also start and end with this.

What i have noticed is the input id usually 95% of the time does end in either _9_1 or _5_1 but i have seen or a rare occasion _7_1

Here is snippet of the html

<table>
<tbody>
	<tr><td style="vertical-align: top; white-space: pre-wrap;" class="masterPrompt promptLabel promptLabelLeftAlign">
	<label for="saw_1063346_9_op" title="Division"><span>Division</span>
	</label>
	</td>
	</tr>
<tr>
 <td style="vertical-align: middle; text-align: left;">
  <span>
   <span class="data promptControlNarrowView" style="white-space: nowrap;">
    <div>
	 <div style="white-space: nowrap; vertical-align: bottom; width: 120px;" class="masterCustomDropDown">
	  <input id="saw_1063346_9_1" type="text" class="promptTextField" tabindex="0" title="North" style="width: 97px;">
	  <img id="saw_1063346_9_1_dropdownIcon" tabindex="-1" src="/analytics/res/v-DBoTHFvj6ls/s_Alta/master/selectdropdown_ena.png" 
	  title="" alt="" style="cursor: pointer;" class="promptComboBoxButtonMoz" closingdropdownmenu="false">
	  <div style="width: 0px; height: 0px; overflow: hidden; position: absolute; z-index: 1;">
	  <label id="saw_1063346_9_1_aria_label">
	  <span><span stext="">
	  </span>
	  <span stext=". ">. </span>
	  <span stext="Division">Division</span>
	  <span stext=", ">, </span>
	  <span stext=""></span>
	  <span stext=", ">, </span>
	  <span stext="Multiple Values ComboBox">
I have tried using the below with no success:
try:
    elem = driver.find_element_by_xpath("//input[starts-with(@id, 'saw') and contains(@id, '_9_1')]")
    elem.clear()



Help and thoughts much appreciated.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to find element in a deeply nested html structure Orientation_group 5 1,271 Oct-09-2023, 10:13 AM
Last Post: Larz60+
  Selenium suddenly fails to find element Pavel_47 3 6,296 Sep-04-2022, 11:06 AM
Last Post: Pavel_47
  Find element using xpath engli 3 3,929 May-20-2020, 08:56 AM
Last Post: Larz60+
  find element...click() dont work windows11 6 3,131 Apr-23-2020, 11:13 PM
Last Post: law
  bypassing find element click() windows11 1 1,878 Apr-02-2020, 11:55 AM
Last Post: Larz60+
  How find link element zinho 3 3,116 Mar-31-2020, 12:29 PM
Last Post: snippsat
  How to find which frame/iframe my element belongs to? smaria 1 2,049 Nov-18-2019, 09:21 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