r/selenium • • Sep 21 '20

Python/selenium

Can someone help with why I am getting this error? I am new to scripting but this has had me stuck for a few days now. (I have to use internet explorer). Thanks so much for all your help!

ERROR: selenium.common.exceptions.NoSuchElementException: Message: Unable to find element with css selector == input.k-textbox

HTML: <input class="k-textbox" type="text" placeholder="User Name" data-bind="attr: {maxlength: _maxLength, style: _style, placeholder: _placeholder}, disable: _disabled, textInput: _value, setFocus: _viewActions, focus: _hasFocus">

driver = webdriver.Ie(IEDriverManager().install())
#this will open up the HighJump Site
url = "http://hjweb.theblacktux.net:30000/workspace/Default.html"
driver.get(url)
driver.implicitly_wait(20)
username = driver.find_element_by_css_selector("input.k-textbox")
username.send_keys("sa")
driver.find_element_by_name("submit").click()
0 Upvotes

7 comments sorted by

2

u/ps4facts Sep 22 '20

Try find element by class name instead?

1

u/ProfCrumpets Sep 22 '20

Can you wait until element is visible first, then click it?

It may not be present when the page loads and the script start.

1

u/cookiemon32 Sep 22 '20

You would have to enter delay. But inspect and look at page actually loading to determine. Probably some type of anti scraping tactic.

Are you sure you are using right selector?

1

u/ProfCrumpets Sep 22 '20

If the element is as described in the post, that selector should work.

You could try something like this.

from selenium.webdriver.support import expected_conditions as expectedConditions

wait = WebDriverWait(driver, 10)
element = wait.until(expectedConditions.element_to_be_clickable((By.CSS_SELECTOR, 'input.k-textbox')))

1

u/TIMTBTBTBT Sep 22 '20

e_click

I will give this a try

1

u/TIMTBTBTBT Sep 22 '20

how would i define Wait? I get 'wait' and 'WebDriverWait'is not defined