I am trying to simply insert text into a textarea on a page, nothing I have tried or found on the internet has worked. When I try to either click the element or send keys to it I get an error saying that the element is not interactable, a wait doesn't solve this since if I make an explicit wait to wait until it becomes interactable it just times out every time, meaning it never becomes interactable.
This is the html of the textarea I am trying to target:
<textarea _ngcontent-kjr-c428="" placeholder="Enter Description" name="description" maxlength="120" required="" class="input-text ng-pristine ng-invalid ng-touched"></textarea>
I did also try sending text in there with javascript, but didn't manage to succeed, simply nothing happened.
Any help is appreciated since I am truly and utterly stuck
my code:
descriptionInput = wait.until(presence((By.NAME, 'description')))
descriptionInput.click()
descriptionInput.send_keys("Test")
The issue was, as #JaSON pointed out, that there were indeed more elements named description
Related
I'm working with a website where send_keys sometimes works and sometimes doesn't (I have no idea why). Sometimes it sends keys then I try a few hours later and it doesn't work anymore. I was wondering if anyone knew a way to send text/numbers into a input element WITHOUT using send_keys.
For example, would it be possible to input text into the following element without using send_keys:
<input _ngcontent-coh-c546="" type="text" name="tag" maxlength="25" placeholder="Tags" class="ng-dirty ng-valid ng-touched">
Any help would be greatly appreciated. Thank you.
This should work effectively and faster compared to send_key
from selenium import webdriver
driver = webdriver.Chrome('chromedriver')
driver.get("http://www.google.com");
driver.execute_script("document.getElementsByName('q')[0].value='What ever you want to be typed here'")
I know there are lots of posts about this exception, and I've read lots of them and tried their suggestions but they don't seem to work. Maybe you guys can see what I'm doing wrong.
I'm trying to scrape this page: https://www.kichink.com/stores/barshop
Specifically the information inside the little popup that apppears when clicking the "i" button next to the green "SEGUIR" button.
The HTML for that button is this:
<button id="about" class="btn btn-default btn-info-store" data-toggle="popover" data-original-title="" title=""></button>
I've tried many things to click it, but I just keep getting the element not interactable exception.
My last attempt was with:
element_boton = wd.find_element_by_class_name("btn.btn-default.btn-info-store")
element_boton.click()
The button seems to be correctly found, but I just can't click it.
Any suggestions?
Well, I have no idea why (so maybe someone can shed some light) but after using the full xpath (for some reason not even the relative xpath worked, it had to be the full one) to search for the button, it just started working, and i was able to click it.
element_boton = wd.find_element_by_xpath('/html/body/div[1]/div[3]/div/header/div/nav[2]/div/div['
'2]/div/ul[2]/li[1]/button')
I've perused SO for quite a while and cannot find the exact or similar solution to my current problem. This is my first post on SO, so I apologize if my formatting is off.
The Problem -
I'm trying to find a button on a webpage to punch me into a timeclock automatically. I am able to sign in and navigate to the correct page (it seems the page is dynamically loaded, as switching from different tabs like "Time Management" or "Pay Period" do not change the URL).
Attempts to solve -
I've tried using direct and indirect XPaths, CSS Selectors, IDs, Classes, Names, and all have failed. Included below are the different code attempts to find the button, and also a snippet of code including the button.
Button - HTML
Full Page HTML Source Code
<td>
<a onclick="return OnEmpPunchClick2(this);" id="btnEMPPUNCH_PUNCH" class="timesheet button icon " href="javascript:__doPostBack('btnEMPPUNCH_PUNCH','')">
<span> Punch</span></a>
<input type="hidden" name="hdfEMPPUNCH_PUNCH" id="hdfEMPPUNCH_PUNCH" value="0">
</td>
Attempts - PYTHON - ALL FAIL TO FIND
#All these return: "Unable to locate element"
self.browser.find_element_by_id("btnEMPPUNCH_PUNCH")
self.browser.find_element_by_xpath("//a[#id='btnEMPPUNCH_PUNCH']")
self.browser.find_element_by_css_selector('#btnEMPPUNCH_PUNCH')
#I attempted a manual wait:
wait=WebDriverWait(self.browser,30)
button = wait.until(expected_conditions.element_to_be_clickable((By.CSS_SELECTOR,'#btnEMPPUNCH_PUNCH')))
#And even manually triggering the script:
self.browser.execute_script("javascript:__doPostBack('btnEMPPUNCH_PUNCH','')")
self.browser.execute_script("__doPostBack('btnEMPPUNCH_PUNCH','')")
#Returns Message: ReferenceError: __doPostBack is not defined
None of these work, and I cannot seem to figure out why that is. Any help will be greatly appreciated!
I'm currently trying to locate Microsoft Sign In page's email input box by using xpath (others as well) but after many tries I still can't locate the correct element for it.
After copying the element from the page, this is the element given:
<input type="email" class="form-control" placeholder="Email, phone, or Skype" aria-required="true" spellcheck="false" autocomplete="off" data-bind="
hasFocus: focus,
textInput: email,
attr: {'placeholder': config.text.emailPlaceHolder, 'aria-invalid': !error}">
And this is currently my python code:
login = browser.find_element_by_xpath("//input[#class='form-control']")
login.send_keys(config.username)
login.send_keys(Keys.RETURN)
I had tried multiple times but I still can't get the proper element to proceed. After entering https://forms.office.com/ I had successfully captured the sign in element but stuck at the next page.
Please NOTE that this is similar to this question but is not the same as the page element is quite different. Any help would be greatly appreciated!
Your target element is present in an iframe with id as hrdIframe. So you have to switch to the frame before interacting with the element.
driver.switch_to.frame('hrdIframe')
driver.find_element_by_xpath("//input[#type='email']").send_keys(config.username)
Always make sure you switch back to default frame once you are done with the actions in iframe.
I want to send 'username' using Selenium python, for the following html:
<div class="entryforms-elements">
<input id="entryforms-control-element" class="entryforms-element-text" type="text" autocomplete="off"></input>
</div>
But none of the following method worked:
browser.find_element_by_xpath('//input[#id="entryforms-control-element"]').send_keys('username')
browser.find_element_by_id('entryforms-control-element').send_keys('username')
browser.find_element_by_class_name('entryforms-element-text').send_keys('username')
Please help me!
You might want to check the size of the found element to be sure you are actually locating something.
If you are using firefox this might be getting in the way:
selenium webdriver is clearing out fields after sendKeys had previously populated them
Or some javascript might be munging the field after your keys are sent (maybe some js firing after page load).
You also might try calling click() first and then sending the keypresses -- perhaps that will help focus the element if it's the issue mentioned above or something similar.
Are you sure that the select by Xpatch is correct?
in my opinion should be something like that:
browser.find_element_by_xpath(".//*[#id='entryforms-control-element']")
in every case just to be sure is better you clean and then you introduce your input
browser.find_element_by_xpath(".//*[#id='entryforms-control-element']").clear()
browser.find_element_by_xpath(".//*[#id='entryforms-control-element']").send_keys('username')
in any case I advice you to use Firefox with the plugin firebug and firepath to know for sure the correct xpath of the elements
Jump on your browser developer tools and check how long it takes the element to load in the network tab. Then set a wait in your code between the load and element find based on this information.