How to open and operate in different browser tabs(Selenium,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 2 years ago.
Improve this question
Like I have to open different tabs of same url lets say www.seleniumhq.com and then operate differently in each tab.... Pls help!!!
I just want to open same url in different tabs and be able to switch to different tabs in browser –

For example if you want to open the same url in 3 new tabs (4 tabs in total), you can try something like this:
from selenium import webdriver
url = 'https://www.selenium.dev/'
driver = webdriver.Chrome()
driver.get(url)
for x in range(3):
driver.execute_script("window.open('');")
driver.switch_to.window(driver.window_handles[len(driver.window_handles)-1])
driver.get(url)

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

XPath locator is not Working on this webpage [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 3 years ago.
Improve this question
I would like to click the Table of content list using Xpath, but Xpath is completely not working in this URL
https://www.hindawi.com/journals/ecam/contents/
Use CSS Selector in place of XPath as follow :
CSS Selector : a[href='/journals/ecam/2019/']
Code to click :
content = driver.find_element_by_css_selector("a[href='/journals/ecam/2019/']")
I don't know why you are having problems with XPath...
This code snip works fine for me:
from selenium import webdriver
driver = webdriver.Chrome(r'C:\path\to\chromedriver.exe')
driver.get('https://www.hindawi.com/journals/ecam/contents/')
driver.find_element_by_xpath('//*[#id="TableofContentsNav"]').click()
all_links = driver.find_elements_by_xpath('//*[#class="middle_content"]//*[#href]')
for i in all_links:
print(i.get_attribute('href'))
Hope you find this helpful!

How to start Selenium (Chrome Driver) on a profile, with cookies etc inherited, on 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 5 years ago.
Improve this question
Experimenting with things on Python, and want Selenium to fill out a form that is only available after adding something to a cart. I'm not sure how to set it up to have cookies/a profile on it beforehand. How would I do it?
you need to start chrome using the user-data-dir command-line switch to specify the custom profile to use (otherwise it will create a new temporary profile).
For example:
options = webdriver.ChromeOptions()
options.add_argument('user-data-dir=/path/to/profile')
driver = webdriver.Chrome(chrome_options=options)
/via https://sites.google.com/a/chromium.org/chromedriver/capabilities

Python Automation [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 5 years ago.
Improve this question
I'm trying to capture a test case result where table content Search/filter output need to cross check each time when the test run. I have attached a table grid that I need to use to search/filter. I'm using python script for the automation.
Any suggestion?
You can use selenium to test. The table's inner HTML can be accessed using
table_content = element.get_attribute('innerHTML').
you can parse that HTML to cross check your results.
Have a look at this question for reference.
Get HTML Source of WebElement in Selenium WebDriver using Python

automate web browsing using 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 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()

Categories

Resources