Agus Mayadi
Agus Mayadi

Reputation: 1

How to click on element with selenium in python on this page?

1

https://iphone.facebook.com/marketplace/selling/item/

base on image that i've upload, i have to fill some column and click few button to post product. i still try to create selenium bot automation to do it but i have problem on clicking the button element like, post button, category (not button but i have to click it to show its option) and last one is location (not button to but have to click it to show the column).

i have csv file as source of data, and i write code below to fill data ;

        scraper.element_send_keys('input[name="title"]', data['Title'])
    scraper.element_send_keys('input[name="price"]', data['Price'])
    scraper.element_send_keys('textarea[name="description"]', data['Description'])

what i need now is click on post button and fill the location and category with data from csv file.

sorry for my bad english but i need help.

Thank you.

I have try using xpath, id and name tag to locate the element for click but not work.

i want code that can click on button and column that i mention above.

Upvotes: 0

Views: 60

Answers (1)

Rishabh Sharma
Rishabh Sharma

Reputation: 101

I think, you should use .keys to click on the post button, and using the id is a good idea.

from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By

driver.impicitly_wait(4) 
post_button = driver.find_element(By.ID, 'u_0_25_2e')
post_button.send_keys(Keys.'RETURN')

or 
post_button = driver.find_element(By.ID, 'u_0_27_ty')
post_button.send_keys(Keys.'RETURN')

you can open try, except block or use driver.wait until expected conditions.

Hope it helps.

Upvotes: 1

Related Questions