Xpath issue with two web applications

When am navigating from one web application to other web application xpath is not locating correctly i.e its throwing an error like Element not found. Is there is any solution for this problem.

eg: www.gmail.com -->one web application
www.facebook.com -->other web application

Hi @lakshmipriya_a can you share your recording to see the details of the process and how you switch between the applications?

example : I am taking values from first web application and pasting and searching it in second web application and I need to compare the values between two web applications.

Here am facing the issue with xpath , even though it is same web application when am navigating to next page xpath is not working . even with second application.

@lakshmipriya_a you can use Xpaths only if you open the application using Open website action.
How do you open the second application, using keystrokes? In this case, if you want to switch between several tabs and use Xpaths on both, you can use this custom action script.

Hope it helps.

xpathsample.zip (1.0 KB)

@ashapkina Here am using two web applications ,after navigating to second web application when am navigating to previous tab of first web application. In step 15 its throwing an error “Element not found”.

kindly help me with this issue.

@lakshmipriya_a you don’t need to use Switch to browser the first Custom script in this recording.

Switch to browser is only used when you want to switch to browser from some other application you worked with (notepad, file explorer etc.), there is no need to use in this script after mouse click - the focus is already on the browser.

The custom script can switch between tabs that are open in the browser at the same time, or if a link opens in another tab. The applications you use open links in the same tab, so there is no need to switch to a new page.

The last web element doesn’t work because you need to click in on page https://www.tutorialspoint.com/ , but you already left this page and opened page https://www.tutorialspoint.com/css_online_training/index.asp, so the bot cannot find the element.

To go back to the previous page, you need to use keystrokes Alt+Left, and switch to it using custom action as in the example. I have attached the corrected script.
xpathsample_updated.zip (855 Bytes)

@ashapkina I want to get element from www.w3schools.com after opening www.tutorialspoint.com application. actually am working with two application, so I want both web applications should work.
for example in this www.w3schools.com applications after 5 steps i’ll be opening the www.tutorialspoint.com (3 page/3 tab) and again I want do to mouse click action in www.w3schools.com i.e (2 page/2 tab) this is the scenario . when am going back to 2 page/2 tab ,its throwing an error element not found.

@ashapkina please help me

@ashapkina please see the above comments and attachments .kindly give me a solution for this issue.

@lakshmipriya_a if you need both websites to be openув in the browser at the same time, you need to open the second one using keystrokes and then switch to it using the custom action. Then you can switch back and forth between two tabs using custom actions.

If you open the second one using Open website, it will open instead of the first website, not in another tab.

Let me know if you still have issue with this.

xpathsample_updated.zip (1.1 KB)

@ashapkina in step 11 its throwing an error.

I just played it, and step was executed successfully.

However, step 15 fails because:

  • in the Custom action you need to switch to previous window, not last window.

@CustomScriptAction(
)

def customScript() {
   switchToPrevWindow()
}
  • element //*[@id="main"]/div[2]/a[1] doesn’t exist on any of the windows opened at that time. Maybe, there is an error in the Xpath?
1 Like

@ashapkina thank you so much ,now its working .:clap::bouquet:

1 Like

Glad it helped :grinning:

1 Like