2

I am scraping his website. To create an account. Below is the url

https://sjobs.brassring.com/TGnewUI/Search/Home/Home?partnerid=25222&siteid=5011&noback=1&fromSM=true#CreateAccount

After going to this site, click on "Dont have an account yet?" and click "Agree" on the next page.

There I have security questions to fill. For that I wrote the below script.

def findxpath_AddKey(xpath, key1, id, key2):
    element = browser.find_element_by_xpath(xpath)
    element.click()
    browser.execute_script("arguments[0].setAttribute('aria-activedescendant',{})".format(key1),element)
    span = browser.find_element_by_id(id)
    browser.execute_script("arguments[0].innerText = {}".format(key2), span)
    browser.execute_script("arguments[0].setAttribute('class',\"ui-selectmenu-button ui-button ui-widget ui-selectmenu-button-closed ui-corner-all\")",element)

findxpath_AddKey('//*[@id="selectSecurityQuestion1-button"]',"'ui-id-3'", 'selectSecurityQuestion1-button_text', "'Where is your favorite vacation spot?'")

Above process is repeated for other security questions and click "continue". But the website is throwing errors, saying that to fill security questions.

The error in the page

1 Answer 1

1

I'm not sure if this will solve your problem or not, but I do know that, sometimes, manually editing the inner text of a form will not register as a form being filled out—and that's what I believe you're doing by using setAttribute.

Instead of setAttribute, try using the driver's send_keys method. It would look something like this:

form_field = browser.find_element_by_id('ID_OF_FORM_FIELD')
form_field.send_keys('Answer to security question')

You don't have to use the id to find the field, either. You could use find_element_by_xpath or whatever other identifier you can think of.

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.