Issue: Unable to interact with elements on a specific webpage after opening a new tab.
Using WebDriver Chrome.
I can successfully navigate the initial webpage until I click a link that opens a new tab, at which point I am unable to perform any actions.
Here is what I have tried after thorough investigation:
1- After switching to the new tab using driver.switch_to.window, I confirmed the correct page title was displayed.
2- I attempted both implicit and explicit waiting methods (including time.sleep) to ensure the page fully loaded.
3- Although there were no iframes present, I checked the number of frames (2) and switched between them, trying to locate elements using full xpath without success.
4- Attempted to maximize the window.
Despite trying various approaches, including inspecting the elements revealing JavaScript functions with arguments, such as:
href="JavaScript:SWESubmitForm(document.SWEForm2_0,s_10,"s_2_1_96_0","VRId-0")" tabindex="2997" id="s_2_1_96_0">Track Faults
Further investigation uncovered that s_10 is a variable within the script containing different options from s_0 to s_14.
var s_0 = {action:"/esales_enu/start.swe",target:"_sweview",SWECmd:"GotoView",SWEMethod:"GotoView",SWEView:"L2C Track Channel Reference View BT",SWEApplet:"L2C New CZ Home Page Applet BT",SWEReqRowId:"0",SWESP:"false",SWENeedContext:"true",SWEKeepContext:"0",SWEDIC:"false"}; var s_10 = {action:"/esales_enu/start.swe",target:"_sweview",SWECmd:"GotoView",SWEMethod:"GotoView",SWEView:"New Portal Fault Search View ORH BT",SWEApplet:"L2C New CZ Home Page Applet BT",SWEReqRowId:"0",SWESP:"false",SWENeedContext:"true",SWEKeepContext:"0",SWEDIC:"false"};
In an attempt to execute the JavaScript function using driver.execute_script(), I inputted:
driver.execute_script("SWESubmitForm(document.SWEForm2_0,s_10,'s_2_1_96_0','VRId-0')")
The above code resulted in the following error:
selenium.common.exceptions.JavascriptException: Message: javascript error: SWESubmitForm is not defined
What could be the missing element here? Is it a syntax issue? Any guidance on how to proceed would be highly appreciated.
Thank you.