enter image description hereBelow is the script that I wrote, and it goes well with initial steps but it starts to stop working where I have to click and it opens a popup box where i have to send keys and click close.
package pages;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.testng.annotations.Test;
import appSetup_Maven.test.BaseClass;
public class UploadFile extends BaseClass {
#Test
public void logout() throws IOException {
Login();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
}
#Test
public void uploadFile() throws Exception {
driver.findElement(By.xpath(".//*[#id='sidebar-menu']/ul/li[5]/a/span[1]")).click();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.findElement(By.xpath(".//*[#id='sidebar-menu']/ul/li[5]/ul/li[4]/a/span")).click();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.findElement(By.xpath(".//*[#id='drives-gridview']/table/tbody/tr[1]/td[1]/a")).click();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.findElement(By.xpath(".//*[#id='wrapper']/div[3]/div/div[2]/div[2]/div/div[2]/div/a[1]")).click();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.findElement(By.xpath(".//*[#id='explorer-content']/div[2]/div/div/div/div[2]/div/div[1]/div/div[1]/button[2]")).click();
driver.findElement(By.xpath(".//*[#id='folderName']")).sendKeys("Test");
driver.findElement(By.xpath(".//*[#id='folderName']")).sendKeys("Test");
driver.findElement(By.xpath(".//*[#id='createFolderForm']/div[3]/button[2]")).click();
}
When execute above code, I got this Error:
JavaScript warning: www.wwwww.com/assets/js/clipboard.min.js, line 1:
mutating the [[Prototype]] of an object will cause your code to run
very slowly; instead create the object with the correct initial
[[Prototype]] value using Object.create
************************************************************
* Call to xpconnect wrapped JSObject produced this error: *
[Exception... "[object Object]'[object Object]' when calling method: [nsIConsoleListener::observe]" nsresult: "0x8057001c
(NS_ERROR_XPC_JS_THREW_JS_OBJECT)" location: "native frame ::
:: :: line 0" data: no]
************************************************************
************************************************************
* Call to xpconnect wrapped JSObject produced this error: *
[Exception... "[object Object]'[object Object]' when calling method: [nsIConsoleListener::observe]" nsresult: "0x8057001c
(NS_ERROR_XPC_JS_THREW_JS_OBJECT)" location: "native frame ::
:: :: line 0" data: no]
************************************************************
JavaScript warning: , line 0: https://hq20m-161112.wwww.com:10036/js/iframeResizer.contentWindow.min.js
is being assigned a //# sourceMappingURL, but already has one
************************************************************
* Call to xpconnect wrapped JSObject produced this error: *
[Exception... "[object Object]'[object Object]' when calling method: [nsIConsoleListener::observe]" nsresult: "0x8057001c
(NS_ERROR_XPC_JS_THREW_JS_OBJECT)" location: "native frame ::
:: :: line 0" data: no]
************************************************************
Not sure why i am getting this error. All i am trying to do is to
click an element on the webpage, enter text in the popup and click the
button on the popup to close that popup box.
For this: - All i am trying to do is to click an element on the webpage, enter text in the popup and click the button on the popup to close that popup box.
You need to do following things :-
1) Once the pop-up is generated, switch to that pop-up
2) Now you can communicate with the elements present on that pop-up like text field where you are going to send keys.
3) Then click on button to close the pop-up
Code for this is :-
1) After clicking on link, and when pop-up opens, write this.
Alert alert=driver.switchTo().alert();
2) To send data to the text field :
alert.sendKeys("Text");
3) To close the pop-up :
alert.accept();
Or else you can use : after opening the pop-up do this.
driver.switchTo().activeElement();
I hope this will work for you.
Related
I am trying to pop up a Confirmation Dialog (dialog.confirm(options)) as soon as one clicks on Submit Button on my Suitelet. For this, I am using saveRecord Entrypoint in Clientscript. Below is the code
function saveRecord() {
//alert('Inside Save Record');
var options = {
title: "I am a Confirmation",
message: "Press OK or Cancel"
};
function success(result) {
console.log('Success with value ' + result);
}
function failure(reason) {
console.log('Failure: ' + reason);
}
dialog.confirm(options).then(success).catch(failure);
}
Upon execution, I am getting the dialog box, but on clicking OK I am unable to move further. (that is from Suitelet GET to Suitelet POST).
Please Note - I am using SuiteScript 2.0
Given the code provided when you press "Ok" there is no further actions (redirect to Suitelet) defined. If you want to trigger the Suitelet after user presses okay add the redirect to the success function. The "redirect.toSuitelet(options)" method is not available for Client scripts but you can use window.open(URL); to point the user to the suitelet.
On saveRecord, you either return true; to proceed or return false; to stay on the page.
If you return true from the success then it won't serve to confirm your saveRecord. It's returning from a different context. One workaround could be to use the native browser window.confirm as this executes synchronously.
I created a GUI with a button in PowerShell. If user presses this button a popup window will appear and ask for a password. If the password was 123, then the GUI should be reloaded with some extra options.
I wrote the following function for this button:
Function AdminPanelPass() {
if ($TextBox91.Text -eq $adminpanelpass) {
$script:admin = 1
$form9.Dispose()
$script:form.Dispose()
[void]$script:form.ShowDialog()
}
}
This function is called if the button is pressed. It reads the password from the TextBox91 on the form9. If the password was not 123, form9 is closed and after that the main form will be reloaded. Upon reloading the main form there is a check for $admin.
The problem is that after the form is closed, it won't open again. The error is:
Exception calling "ShowDialog" with "0" argument(s): "Form that is
already displayed modally cannot be displayed as a modal dialog box.
Close the form before calling showDialog."
Can anyone assist please? Is that a correct way to be doing such a thing?
Found a way it works:
Function AdminPanelPass(){
if ($TextBox91.Text -eq $adminpanelpass){
$script:admin = 1
$form9.Dispose()
$form.Dispose()
MakeForm
}
}
MakeForm is the function to create the main form
I have been trying to get my Automation Tests up and Running but keep running into some Xpath Errors. I am having 5 errors all with missing/not being able to locate the Xpath that I have wrote. I need to have my test click on a "Refresh" Button located in a data table that is located on the Web page. Button instead of clicking on the button I get the error below. The ID of the button is "SF-Refresh" .
#When("I click refresh button")
#Given("I click refresh button")
#Then("I click refresh button")
public void clickRefreshButton() {
By linkSelect = new By.ByXPath("//*[#id=\"SF-Refresh\"]");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
LightningButton.click(linkSelect);
}
Error:
Unable to locate the requested element: By.xpath: //*[#id="SF-Refresh"]
There is few possible error as below:
1) The Xpath is might wrong or same Xpath return multiple elements, the xpath must return one element only if you are using findElement
2) The element is might not load properly yet or not ready for action use below:
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[#id="SF-Refresh"]")));
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[#id="SF-Refresh"]")));
LightningButton.click(linkSelect);
I am unable to click on sign in button in mobile using Appium.
I have used xpath & androidUiAutomator but unable to succeed.
Following are the details:
For Xpath i used:
//android.widget.TextView[#text='Sign In']
For AndroidUiAutimator i used:
return driver.findElementByAndroidUIAutomator("text(\"Sign In\")");
public void MainLogin() throws InterruptedException {
System.out.println("Enter in Epcl_MainLogin");
TouchAction touch=new TouchAction(driver);
WebDriverWait wt=new WebDriverWait(driver,20);
LoginPom objLogin = new LoginPom(driver);
wt.until(ExpectedConditions.visibilityOf(objLogin.LoginName()));
objLogin.LoginName().sendKeys("Testa");
TimeUnit.SECONDS.sleep(2);
driver.hideKeyboard();
objLogin.LoginPassword().sendKeys("Testb");
TimeUnit.SECONDS.sleep(4);
driver.hideKeyboard();
objLogin.BtnLogin().click();
System.out.println("Button Clicked Successfully");
TimeUnit.SECONDS.sleep(8);
System.out.println("Login Successfully");
}
you can add content-description to your sign in button (in your android code). Then you will be able to click the button by using
driver.findElementByAccessibilityId("your content description").click()
You can also add id to your button and click it using:
driver.findElementById("you button id").click();
Using xpath in appium is not recommended
I have a problem with Dojo in Internet explorer 7/8 (this works fine in Firefox).
Basically I have a tab container with a number of tabs in it (these are dojox.layout.ContentPane's). On one of these tabs I want to have a "comments box" which would popup a dialog and ask the user to put something in. The comment is then saved by an call to the back end and I want the tab to reload to show the new comment.
The logic of my save button works something like this:
<button data-dojo-type="dijit.form.Button" type="button" data-dojo-props="iconClass:'dijitIcon dijitIconSave', showLabel: true" title="Add your comment">Add Comment
<script type="dojo/on" data-dojo-event="click" data-dojo-args="evt">
require(["dojo/dom"], function(dom)
{
var tText = dijit.byId('comment_70').get('value');
if (tText == '')
{
alert('You have not entered any comment');
return;
}
var tJSONRPC = new JSONRpcClient('JSON-RPC');
try
{
tJSONRPC.be.addComment('70', tText);
var tTab = dijit.byId('Detail_70');
tTab.refresh();
}
catch (Ex)
{
alert(Ex);
}
});
</script></button>
Does not appear to be terrible taxing (the 70 at the end is the ID so that the user can have more than one of these open at the same time, hence the tabs).
As mentioned this works fine in Firefox but not in IE 8/7, it throws an error in some of the generated code within dojo (_32.focus(); to be precise), the error message I get in the debug console is "Unexpected call to method or property access"
Try this, with your line tTab.refresh();:
setTimeout(function() { tTab.refresh(); }, 0); // whenIdle
Its nearly impossible to tell where the thrown exception comes from - you should use the developement dojo-1.M.m-src/dojo/dojo.js code so optimized function- and variable-names are expanded (along with useful commenting once you step-through-debug).
Reason for the above is to eliminate, that exception occurs while handling button onclick-focus event (refresh will tear down DOM in the tab - along with your button)