-1

I am scraping some data from a website. I am writing a script that will automate it. In order to go to the next page I have to remove this disabled attribute from the button. I have tried many things, but nothing has helped me till now.

<button class="proceed" disabled="disabled" >Next</button>

Code:

binary = FirefoxBinary('/usr/lib/firefox/firefox')
driver = webdriver.Firefox(firefox_binary=binary)

driver.get("https://example.com/example/example")

my_url = Request('https://www.example.com/example/example', headers={'User-Agent': 'Mozilla/5.0'})
uClient = uReq(my_url)
page_html = uClient.read()
uClient.close()
page_soup = soup(page_html, "html.parser")

user = raw_input("enter your starting point : ")

user_box = driver.find_element_by_class_name("search")
user_box.send_keys(user)
#user_box.autocomplete = "on"
#user_box.submit()

login_button = driver.find_element_by_css_selector("button.proceed")
#login_button.submit()

#print (login_button.text)
  • You can remove this attribute in code, but I guess as user you will do some steps manually on page to enable this button. What are those steps? – Andersson Feb 17 '18 at 12:55

1 Answers1

2

Use JavascriptExecutor to remove this disabled attribute from the button as follows :

login_button = driver.find_element_by_css_selector("button.proceed")
driver.execute_script("arguments[0].removeAttribute('disabled')", login_button) 
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Sir, I am getting another problem. When I am executing login_button.submit() I am getting an error. raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: ./ancestor-or-self::form. How can I execute the script that will automatically select the next button? – yudhveer singh Feb 17 '18 at 14:41
  • Clearly your [_Locator Strategy_](https://stackoverflow.com/questions/48369043/official-locator-strategies-for-the-webdriver/48376890#48376890) is throwing `NoSuchElementException` which is defined as `./ancestor-or-self::form`. Can you raise a new question along with the relevant _HTML_ please? – undetected Selenium Feb 17 '18 at 14:47