Shweta Save
Shweta Save

Reputation: 27

How to open two links on the same browser

I need to open 2 Invoices the one's whose GST Invoice number contains digit 2 at it's third place. I modified the as following:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome(executable_path=r'D:/Chrome driver/chromedriver.exe') # Get local session(use webdriver.Chrome() for chrome) 

driver.get("URL")



WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//input[@id='PNRId']"))).send_keys("SHFYGW")
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='GstRetrievePageInteraction']"))).click()

toJourney=WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, "table.gst-table-view")))

toJourney.find_element_by_xpath('tbody/tr/td[2]/ul[1]/li[2]/a[1]').click()

toJourney.find_element_by_xpath('tbody/tr/td[2]/ul[3]/li[2]/a[1]').click() 

The first Invoice opens up correctly, but for the second one it gives

ElementClickInterceptedException: element click intercepted: Element <a id="ViewInvoice" invoice-number="MP2192004AA05359" is-print="false" href="#" target="_blank" class="gst-view-print-btn ViewInvoice clsDtmPageInteraction" name="ViewInvoice">...</a> is not clickable at point (490, 559). Other element would receive the click: <a href="#" style="color: #f6e292">...</a>
  (Session info: chrome=85.0.4183.102)

What wrong am I doing here?

Upvotes: 0

Views: 78

Answers (1)

bot8080
bot8080

Reputation: 44

It is working fine.. with the following code.. I already checked it. It opened both of the pdfs in two different tabs.

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.webdriver.support import expected_conditions as EC

def chrome_arguments():
    user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0'
    options= webdriver.ChromeOptions()
    options.add_argument('--incognito')
    options.add_experimental_option("excludeSwitches", ["enable-automation"])
    options.add_experimental_option('useAutomationExtension', False)
    options.add_argument("--disable-plugins-discovery")
    options.add_argument('--disable-extensions')
    options.add_argument('--profile-directory=Default')
    options.add_argument("--start-maximized")
    options.add_argument("--no-sandbox")
    options.add_argument('--ignore-certificate-errors')
    options.add_argument('--safebrowsing-disable-download-protection')
    options.add_argument('--safebrowsing-disable-auto-update')
    options.add_argument('--disable-client-side-phishing-detection')
    options.add_argument(f'user-agent={user_agent}')
    
    return options
    
driver = webdriver.Chrome(executable_path='',options=chrome_arguments()) 

driver.get("URL")



WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//input[@id='PNRId']"))).send_keys("SHFYGW")
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='GstRetrievePageInteraction']"))).click()

toJourney=WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, "table.gst-table-view")))

toJourney.find_element_by_xpath('tbody/tr/td[2]/ul[1]/li[2]/a[1]').click()

toJourney.find_element_by_xpath('tbody/tr/td[2]/ul[3]/li[2]/a[1]').click()

Upvotes: 1

Related Questions