automate web browsing using python [closed] - python

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
from selenium import webdriver
chromedriver = 'C:\\chromedriver.exe'
browser = webdriver.Chrome(chromedriver)
browser.get('http://www.example.com')
Then, how can I click on the third Download button?

You can use a xpath expresion to get all inputs with a "Download" value, and click the third:
browser.find_elements_by_xpath('//input[#value="Download"]')[2].click()

Related

Perform a click on a web app with selenium python [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I am trying to scrape or crawl this web app (https://www.ea.com/en-gb/fifa/ultimate-team/web-app/)
I not sure if its because its a web app or some anti scraper measures but nothing is happening when I attempt to click the login button.
the button is clicked but doesn't show anything.
Code
driver = webdriver.Chrome('/Users/Downloads/chromedriver')
driver.get("https://www.ea.com/en-gb/fifa/ultimate-team/web-app/")
driver.implicitly_wait(20)
driver.find_element_by_xpath('//*[#id="Login"]/div/div/button[1]').click()
Try this code :
driver = webdriver.Chrome('/Users/Downloads/chromedriver')
driver.get('https://www.ea.com/en-gb/fifa/ultimate-team/web-app/')
driver.implicitly_wait(20)
driver.find_element_by_xpath('//*[#id="Login"]/div/div/button[1]').click()
you simply didn't add the quotes to the url

How can I check if element exists, close selenium driver if it does and if it doesn't continue with the script in Python [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
How can I check if the element exists, close driver if it does and if it doesn't continue with the script in Python
Something like
driver.findElement(webdriver.By.id('*****'));
close.driver()
Exactly what the title says.
How about using 'try' and 'except' like this:
try: driver.findElement(webdriver.By.id('*****'))
except: driver.close()

How do I change the timezone of Selenium in Python [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I have been googling but there seems no adequate answers, I assume Selenium grabs it from my computer, but I should be able to feed it something else no?
The browser date/time functions are all JavaScript. You should be able to use Sinon.JS or TimeShift.JS to mock the date/time:
https://sqa.stackexchange.com/questions/8838/faking-system-time-date-with-selenium-webdriver
or
https://sqa.stackexchange.com/questions/11513/what-is-the-best-way-to-mock-browser-time-and-time-zone-in-selenium

disabling Cookies on phantomjs using selenium with python [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have searched for long time but I could not find how to disable cookies for phantomjs using selenium with python . I couldn't understand the documentation of phantomjs.Please someone help me.
Documentation suggests this driver.cookies_enabled = False, you can use it.

How to insert text or HTML to a specific DOM element by python+selenium+WebDriver? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Could anybody advise, how to insert text or HTML to a specific DOM element by Python + selenium + WebDriver?
You can set the innerHTML value of an element through execute_script():
elm = driver.find_element_by_id("my_id")
driver.execute_script("arguments[0].innerHTML = 'My Text';", elm)

Categories

Resources