My error message is not displaying in my code. Just testing how to use Selenium on Python.
<SPAN class="comment token">#import what I need</SPAN>
<SPAN class="keyword token">from</SPAN> selenium <SPAN class="keyword token">import</SPAN> webdriver
<SPAN class="keyword token">from</SPAN> webdriver_manager<SPAN class="punctuation token">.</SPAN>chrome <SPAN class="keyword token">import</SPAN> ChromeDriverManager
<SPAN class="keyword token">from</SPAN> selenium<SPAN class="punctuation token">.</SPAN>webdriver<SPAN class="punctuation token">.</SPAN>support<SPAN class="punctuation token">.</SPAN>wait <SPAN class="keyword token">import</SPAN> WebDriverWait
<SPAN class="keyword token">import</SPAN> time
<SPAN class="comment token">#set my driver object</SPAN>
driver <SPAN class="operator token">=</SPAN> webdriver<SPAN class="punctuation token">.</SPAN>Chrome<SPAN class="punctuation token">(</SPAN>ChromeDriverManager<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>install<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#go to facebook.com</SPAN>
driver<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'https://facebook.com/'</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#make browser full screen</SPAN>
driver<SPAN class="punctuation token">.</SPAN>maximize_window<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#type the email in the email field</SPAN>
email_field <SPAN class="operator token">=</SPAN> driver<SPAN class="punctuation token">.</SPAN>find_element_by_id<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'email'</SPAN><SPAN class="punctuation token">)</SPAN>
email_field<SPAN class="punctuation token">.</SPAN>send_keys<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"testemail123@gmail.com"</SPAN><SPAN class="punctuation token">)</SPAN>
time<SPAN class="punctuation token">.</SPAN>sleep<SPAN class="punctuation token">(</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#type the password in the password field</SPAN>
pss_field <SPAN class="operator token">=</SPAN> driver<SPAN class="punctuation token">.</SPAN>find_element_by_id<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'pass'</SPAN><SPAN class="punctuation token">)</SPAN>
pss_field<SPAN class="punctuation token">.</SPAN>send_keys<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"testpassword"</SPAN><SPAN class="punctuation token">)</SPAN>
time<SPAN class="punctuation token">.</SPAN>sleep<SPAN class="punctuation token">(</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#click the login button</SPAN>
<SPAN class="comment token">#login_button = driver.find_element_by_xpath('//*[@id="u_0_q"]')</SPAN>
<SPAN class="comment token">#login_button = driver.findElement(By.id("btnLogon"))</SPAN>
<SPAN class="comment token">#login_button = driver.find_element_by_id('btnLogon')</SPAN>
<SPAN class="comment token">#login_button = driver.find_element(By.ID, 'btnLogon')</SPAN>
login_button <SPAN class="operator token">=</SPAN> WebDriverWait<SPAN class="punctuation token">(</SPAN>driver<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">30</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>until<SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">lambda</SPAN> driver<SPAN class="punctuation token">:</SPAN> driver<SPAN class="punctuation token">.</SPAN>find_element_by_id<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'u_0_b'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
login_button<SPAN class="punctuation token">.</SPAN>click<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#find all the text on the screen</SPAN>
body <SPAN class="operator token">=</SPAN> WebDriverWait<SPAN class="punctuation token">(</SPAN>driver<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">30</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>until<SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">lambda</SPAN> driver<SPAN class="punctuation token">:</SPAN> driver<SPAN class="punctuation token">.</SPAN>find_element_by_xpath<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'/html/body'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#body = driver.find_element_by_tag_name('body')</SPAN>
all_text <SPAN class="operator token">=</SPAN> body<SPAN class="punctuation token">.</SPAN>text
<SPAN class="comment token">#verify the error message is displayed</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="string token">"Sorry, something went wrong."</SPAN> <SPAN class="operator token">not</SPAN> <SPAN class="keyword token">in</SPAN> all_text<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">raise</SPAN> BaseException<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"The 'Sorry, something went wrong.' text is not found."</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Test Passed"</SPAN><SPAN class="punctuation token">)</SPAN>
time<SPAN class="punctuation token">.</SPAN>sleep<SPAN class="punctuation token">(</SPAN><SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN>
driver<SPAN class="punctuation token">.</SPAN>quit<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
