Safari Browser Faces Issue with onClick Event in Selenium Automation Using JavaScript

My current automation setup is for Safari Browser on an internal web Application.

Included in my setup are the selenium-safari-driver-2.53.0.jar and Safari Web Driver extension 2.48.0

I can successfully launch my application, but I'm facing a challenge when trying to call a JavaScript function, specifically onClick on a button image that is not functioning as expected.

The HTML code of the button is:

<input onclick="search.viewJournal('','','multiple','preview');" name="0.31.0.9.23" border="0" type="image" src="ntf/images/en_xyz/BtnPreview.gif">

I have attempted two methods:

@Find(By.xpath('path to button'))
WebElement previewBtn 

public void clickOnPreview(){
previewBtn.click();

}


public void clickOnPreview(){
JavascriptExecutor executor = (JavascriptExecutor) driver;

executor.executeScript("search.viewJournal('','','multiple','preview');");

}

Unfortunately, neither option worked, as no event was triggered upon executing the above code.

Answer №1

Upon further investigation of the JavaScript code, it was discovered that the function was indeed being executed. It was observed that in the Safari browser, the "Block Pop Up Windows" setting was enabled by default. After disabling this option, the window.open() function was able to be called successfully.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Retrieve Image URL from RSS Medium Feed

I am attempting to showcase the images from each post in medium's RSS feed using only JavaScript or Angular, without relying on JQuery. I am able to retrieve the title, creation date, and link for each post. Currently, I am developing with Ionic2. en ...

Observing a global object's attribute in Angular JS

Imagine you have an object in the global scope (yes, I know it's not ideal but just for demonstration purposes) and you wish to monitor a property of that object using Angular JS. var person = { name: 'John Doe' }; var app = angular.mod ...

Python script to scrape a webpage after giving consent for cookies

Is anyone able to assist me with a web scraping issue I am encountering? I am attempting to scrape a webpage, but I am facing an obstacle in the form of a cookie acceptance banner that appears before I can access the desired content. I have tried using sel ...

Issue 1068: Attribute not found within angular 2 (Ahead of Time Compilation)

I am currently learning Angular 2 and trying to create a "User Register" form. However, I encountered an error stating "Property does not exist on type" during Phone number validation. I am using both JIT and AOT compilers. With the JIT compiler, my user ...

AngularJS application failing to initialize without a module being included

I'm feeling a bit lost when it comes to angularjs and I have a question about why my angularjs app is refusing to bootstrap without creating a module, even though egghead.io and other tutorials seem to suggest otherwise. Here's a snippet of my HT ...

Struggling with implementing Angular and TypeScript in this particular method

I'm dealing with a code snippet that looks like this: myMethod(data: any, layerId: string, dataSubstrings): void { someObject.on('click', function(e) { this.api.getSomething(a).subscribe((result: any) => { // ERROR CALL 1. It ...

Transfer extracted data into an Excel or text document utilizing Python

I have a question about web scraping. I am currently able to extract HTML links from a website using Python and Selenium, but when I try to save them to an excel or text file, only the last link is being saved. I suspect it has something to do with how I a ...

jQuery datatable loses highlight after page refresh

I am currently working with a datatable that utilizes ajax to load data. var table = $('#example').DataTable({ "ajax": "xxxxxx.aspx", stateSave: true, "aLengthMenu": [ [10, 25, 50, 100], [10, 25, 50, 100] ], ...

Error encountered upon opening an Excel file created using the table2excel jQuery plugin

I am trying to export an HTML table to Excel using the table2excel plugin, but I'm encountering an error in the generated Excel file. How can I resolve this issue? I have set up a JSFiddle demo. To use the plugin, you simply need to follow these ste ...

I am unable to store rich text fields using LocalStorage

My goal is to store form data in localStorage, but I'm facing an issue with rich text fields not saving their data. Regular HTML fields like textboxes work fine. In my Razor markup for the field (using MVC), here is an example: <div class="form-g ...

Having trouble importing a component conditionally within a nested component

I am attempting to dynamically import and render one of two components based on the value returned by a prop (lang). If props.lang is set to spanish, then it should import and render a component named <Spain />; otherwise, <UnitedStates />: /* ...

Using dropzone.js on multiple files in a single webpage

Is it feasible to incorporate multiple dropzone elements on one webpage instead of having numerous file uploads on a single dropzone element? It appears that dropzone fails to trigger after the selection dialog box when there are several elements, each wi ...

Utilizing jQuery Mobile - Dividing content across multiple HTML files

In the process of developing a web application utilizing jQuery and jQuery mobile, I am aiming to display various pages. Given that the corresponding html-markup may become lengthy, I am interested in dividing the html into separate files. For instance: & ...

Utilizing a switch statement for form validation

Currently, I am in the process of creating a form validation that involves two conditions for validation. I'm considering using a combination of switch case and if else statements. Would this be an appropriate approach or is it generally discouraged? ...

"Learn how to seamlessly submit a form and display the results without the need to refresh the

Here is the form and result div: <form action="result.php"> <input type="checkbox" name="number[]" value="11" /> <input type="checkbox" name="number[]" value="12" /> <input type="checkbox" name="number[]" value="13" /> <input t ...

The functionality of setTimeout in Chrome extension is malfunctioning

Greetings everyone, this is my first post here! I'm currently working on a chrome extension where I am utilizing a recursive setTimeout function. Interestingly, I've noticed that setting the timeout to 13 seconds works fine, but anything beyond ...

What is the best way to control the amount of rows displayed in my gallery at any given time?

I need help with customizing my gallery that is dynamically generated from a directory using PHP. My goal is to display only 2 rows of 4 images each, totaling 8 images, with a "show more" button for loading additional rows. How can I set a limit on the n ...

Looping through dates in a POST request using JavaScript/GAS - What's the best approach?

My task involves posting timesheet entries for the upcoming month into a system using an API. In order to do this, I require the following: User ID Assignable ID Dates (in the format YYYY-MMM-DD) Hours Initially, I obtained the user_id and assignable_id ...

I am attempting to select a checkbox with Selenium WebDriver in Python, but encountering an error message: "MoveTargetOutOfBoundsException: move target out of bounds"

As I was attempting to interact with a checkbox on this particular webpage , I encountered some challenges. Initially, I tried using the ActionChains library to click on the checkbox by locating its input tag via xpath or css selector and then using the ...

What is the process for verifying if the dropdown selections align with the UI choices in Selenium WebDriver?

Currently utilizing Selenium WebDriver with Java for scripting purposes. I have saved all dropdown values from the database in a property file and now want to compare these values with the options available in the UI dropdown. The visualization.txt fil ...