vendredi 2 novembre 2018

How can I use selenium python to select a form within a table, chrome browser automation python

please I need your assistance on this

I am trying to use selenium python to select a form with id = 'postform' in the html below and subsequently automate posting to the textarea within the form and click submit with selenium python with no success.

The challenge I have is that selenium is unable to detect the postform id element.

Here is my function and a link to the html of the page

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options

def quick_post():   
driver = webdriver.Chrome(executable_path="/usr/bin/chromedriver")
driver.get("https://www.nairaland.com/login")
driver.find_element_by_name('name').send_keys('Codebrain670090')
driver.find_element_by_name('password').send_keys('password')
driver.find_element_by_xpath("//input[@type='submit' and 
@value='Login']").click()
time.sleep(3)
driver.execute_script('''window.open(" 
https://www.nairaland.com/newpost?topic=4761110","_blank");''')
eleFirstName = driver.find_element_by_xpath("//input[@id='postform']")
print eleFirstName
quick_post()

link to html: https://pastebin.com/568fRpEa




Aucun commentaire:

Enregistrer un commentaire