2

So I have an issue where, I am trying to automate an Import on an application that has no API. As a result, I have to do like 30 navigation clicks just to get to what I want (Exaggeration). However, I am trying to basically automate the clicks that will allow me to upload a specific file. As a result, I almost get to the part where I have to select the specific test build I want to import the file with. There is a field that I need to do a send_keys to find the correct import build I have to upload. The Field element looks like this

<input class="lookupInput" type="text" name="brTestScoreImportLookupInput" id="brTestScoreImportLookupInput" style="width: 100px;" tabindex="1" onkeydown="return lookupKeyPressed(event,&quot;&quot;,&quot;simptbrws000.w&quot;)" origvalue="" det="true" aria-labelledby="" autocomplete="off">

However I don't think my code is properly handling the window as it pops-up from the prior selection. The field I need to update can be found in the picture I uploaded: enter image description here Furthermore the XPATH for the Field is //*[@id='brTestScoreImportLookupInput'] You can find the full code here. The main aspect is I have to Enter TSI into that File ID field and then hit enter on my keyboard to populate the correct import utility I need. Once I do that the import utilities filter out and I need to select a specific File ID: enter image description here.

The main code that should be controlling this:

# Click on Test Score Import Wizard - TW
# Test Wizard XPATH = //a[@id='tree1-3-link']/span
element = WebDriverWait(browser, 20).until(
    EC.element_to_be_clickable((By.XPATH, "//a[@id='tree1-3-link']/span")))
element.click();

# Send test_upload and Send Keys
# Field XPATH = //*[@id='brTestScoreImportLookupInput']
test_lookup = browser.find_element_by_id("brTestScoreImportLookupInput")
test_lookup.send_keys(test_upload)

If you want to visit the link toe repository code click on here above this. Any help would be greatly appreciated.

    Traceback (most recent call last): File ".\skyward_collegeboard_TSI_import.py", line 115, in
    <module> test_lookup = browser.find_element_by_id("brTestScoreImportLookupInput") File "C:\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 360, in find_element_by_id return self.find_element(by=By.ID, value=id_) File "C:\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py",
      line 976, in find_element return self.execute(Command.FIND_ELEMENT, { File "C:\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py",
      line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="brTestScoreImportLookupInput"]"}
      (Session info: chrome=80.0.3987.122)
10
  • >"However I don't think my code is properly handling the window as it pops-up" What happens when you run the code though? Nothing/errors? Commented Feb 25, 2020 at 19:27
  • No I get errors. Let me paste it here Commented Feb 25, 2020 at 19:49
  • No I get errors I will add it to the Question Commented Feb 25, 2020 at 19:50
  • @0buz I have added it to the bottom of the question. Commented Feb 25, 2020 at 19:54
  • Is the element inside an iframe by any chance? Would be good if you could post the html source. But if your element is indeed in an iframe you need to switch first to the iframe before finding the field. Do that with driver.switch_to.frame(>>iframe name or id here) Commented Feb 25, 2020 at 20:18

1 Answer 1

1

So I was able to accomplish this by using the following method using both selenium and pynput.

# Browser Switches to Window
WebDriverWait(browser,10).until(EC.number_of_windows_to_be(2))
browser.switch_to.window(browser.window_handles[-1])

# Send test_upload and oend Keys
# Field XPATH = //*[@id='brTestScoreImportLookupInput']
test_lookup = browser.find_element_by_id("brTestScoreImportLookupInput")
test_lookup.send_keys(test_upload)

# Press and Release Enter Key
keyboard.press(Key.enter)
keyboard.release(Key.enter)

Essentially I had to switch to that popup window.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.