Created
July 25, 2019 13:58
-
-
Save joonvena/06b8a676f7c4a321d17224b54aee68fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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