Skip to content

Instantly share code, notes, and snippets.

@joonvena
Created July 25, 2019 13:58
Show Gist options
  • Save joonvena/06b8a676f7c4a321d17224b54aee68fb to your computer and use it in GitHub Desktop.
Save joonvena/06b8a676f7c4a321d17224b54aee68fb to your computer and use it in GitHub Desktop.
# If page contains acccepted answer
if element_is_present('//div[@class="answer accepted-answer"]'):
answer = driver.find_element(By.XPATH, '//div[@class="answer accepted-answer"]//pre//code')
print("### Answer ###")
print(answer.text)
# If there is no accepted answer get all the code blocks from the topic
else:
code_blocks = wait.until(EC.presence_of_all_elements_located((By.XPATH, '//pre/code')))
for i in range(0,len(code_blocks)):
print(code_blocks[i].text+"\n\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment