title: How can I click this button using selenium?
body: <pre><code>&lt;button name=&quot;main&quot; type=&quot;submit&quot; class=&quot;mainfont&quot;&gt;
  التسجيل&lt;/button&gt;
  </code></pre>
  <p><strong>XPath:</strong></p>
  <pre><code>/html/body/table/tbody/tr[2]/td/table/tbody/tr/td/table[1]/tbody/tr/td[18]/font/button
  </code></pre>
  <p><strong>Full XPath:</strong></p>
  <pre><code>/html/body/table/tbody/tr[2]/td/table/tbody/tr/td/table[1]/tbody/tr/td[18]/font/button
  </code></pre>
  <p>How can I click this button in selenium? I have tried different methods but none worked, some notes:</p>
  <ul>
  <li>There are different submit buttons called &quot;main&quot; with mainfont class</li>
  <li>I tried using the XPath but the function also requires me to use the text inside the button, which is in arabic characters that split into two lines in python text editor, which ofcourse does not work as it needs to be in 1 line, but if I erase the space and make it into one code line, it won't work (probably because it is written in two lines in the HTML code?)
  Edit: added code</li>
  </ul>
  <pre class="lang-py prettyprint-override"><code>    from selenium import webdriver
      from selenium.webdriver.common.keys import Keys
      import time
      from selenium.webdriver.support.ui import WebDriverWait
      from selenium.webdriver.support import expected_conditions as EC
      from selenium.webdriver.common.by import By
      from selenium.webdriver import ActionChains
      #
      
      path = &quot;XXXX&quot;
      driver = webdriver.Chrome(path)
      
      #
      
      driver.get(&quot;XXXX&quot;)
      driver.maximize_window()
      #
      
      login1 = driver.find_element_by_name(&quot;liun&quot;)
      login1.send_keys(&quot;XXXX&quot;)
      time.sleep(2)
      login1.send_keys(Keys.RETURN)
      
      #
      try:
          element1 = WebDriverWait(driver, 100).until(
              EC.presence_of_element_located((By.title_is, &quot;XXXX&quot;))
          )
      finally:
          login2 = driver.find_element_by_name(&quot;gsw&quot;)
          login2.send_keys(&quot;XXXX&quot;)
          login2.send_keys(Keys.RETURN)
          pass
      # THE CODE BELOW DOES NOT WORK
      html = '''
      &lt;button name=&quot;main&quot; type=&quot;submit&quot; class=&quot;mainfont&quot;&gt;\nالتسجيل&lt;/button&gt;
       '''
      driver.get(&quot;data:text/html;charset=utf-8,&quot; + html)
      WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.XPATH, &quot;//button[text()='\nالتسجيل']&quot;))).click()
  </code></pre>