0

HTML:

<div class="emailAttachmentInputMobile">
<input type="text" size="30" maxlength="100" ng-model="emailAttachmentRecipient" class="ng-pristine ng-valid ng-valid-maxlength ng-not-empty ng-touched">
</div>

This is my python code: I have used the following locator strategies:

Using CSS_SELECTOR:

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.emailAttachmentInputMobile input.ng-pristine.ng-valid.ng-valid-maxlength.ng-not-empty.ng-touched[ng-model='emailAttachmentRecipient']"))).clear()

Using XPATH:

WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.XPATH,"//div[@class='emailAttachmentInputMobile']//input[@class='ng-pristine ng-valid ng-valid-maxlength ng-not-empty ng-touched' and @ng-model='emailAttachmentRecipient']"))).clear()

I am getting this error:

raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message:

Could someone please help me resolve this issue. It already took lot of my time but still not able to fix it

eshirvana
  • 23,227
  • 3
  • 22
  • 38
sow
  • 1
  • 1

1 Answers1

0

This worked for me (based on the HTML provided in the query):

driver.find_element(By.XPATH, "//input[@ng-model='emailAttachmentRecipient']").clear()

You may want to extend the XPATH if needed be:

"//div[@class='emailAttachmentInputMobile']//input[@ng-model='emailAttachmentRecipient']"
Anand Gautam
  • 2,018
  • 1
  • 3
  • 8
  • If I use this: "driver.find_element(By.XPATH, "//input[@ng-model='emailAttachmentRecipient']").clear()" or "//div[@class='emailAttachmentInputMobile']//input[@ng-model='emailAttachmentRecipient']" I am getting this error Message: element not interactable – sow Mar 09 '22 at 16:26
  • Could you post more HTML before this line of code, or the website link if possible? – Anand Gautam Mar 09 '22 at 16:28
  • Enter comma separated list of email addresses:
    (Ex: hygy1@yyy.com, ggyu@vjj.com, yfff@gyy.com)
    – sow Mar 09 '22 at 16:42
  • Even with the above HTML, it works like a charm to me. Tried to first input some email id, and then clear it, and it worked spot on: `x = driver.find_element(By.XPATH, "//div[@class='emailAttachmentInputMobile']//input[@ng-model='emailAttachmentRecipient']") x.send_keys("yfff@gyy.com") time.sleep(1) print("Before clear", x.get_attribute('value')) x.clear() print("After clear", x.get_attribute('value')) time.sleep(3)`. Output: `Before clear yfff@gyy.com After clear Process finished with exit code 0`. – Anand Gautam Mar 09 '22 at 16:52
  • Maybe you need some `wait` before coming to this line (since I do not know the whole website behavior leading to this action). If possible share the website link. – Anand Gautam Mar 09 '22 at 16:56
  • I am still facing element not interactable error I cannot share my credentials of website that's the issue – sow Mar 09 '22 at 17:06