Fail to handle light boxes through selenium java webdriver - java

I have a problem. When I click on add button, a light box appears and I need to
Select it or switch focus on it.
Enter name and description in text boxes.
I tried with below code but not succeeded:
d1.switchTo().frame(d1.findElement(By.xpath("locator string of text box Name ")));

Have you looked at Firebug to find out what attributes you can call on the lightbox other than xpath?

Related

Is there any option handle popup using java with selenium which has HTML properties but hasn't any ok/accept/done button?

I'm automating using java selenium
I open flipkart.com in google chrome and as soon as I click on grocery it is asking for verify delivery Pincode but there is no any ok/done button to perform the task. if I open the site manually same Pincode popup is coming and I enter the Pincode then I hit on Enter button it gets open.
I've tried using action class to hit on Enter button however IllegalArgumentException occurring
I have checked mentioned place and it seems that 'Submit' button is activated after a moment after typed code and some validation in background. You might need to add some wait for button to be clickable like here.
Then you can try clicking with xpath like:
//div[text() = 'Submit']
(As there are no many characteristic attributes around).
As for 'IllegalArgumentException' your code sample might be necessary.

Selenium How to get text from notification pop up

Please see below image. This pink color pop up appears for a second and that automatically disappears. How to get text from this pop up in selenium.
It wont stay on screen and disappears with in a second.
enter image description here
It wont stay on screen and disappears with in a second.
It seems your problem is that the popup is not staying on screen for enough time to let you identify html elements to use in your selenium script.
If I'm correct, you can press F8 whenever this message appears to pause the chrome window and then normally identify elements from this message. (using F12: Dev tools)
Depending on the message box, you can use:
If it is alert/popup. You can use:
Alert alert = driver.switchTo().alert();
String text = alert.getText();
If its html just another html element, like div or td. you can use following:
String text= driver.findElement(By.xpath(elementXpath)).getText();
Hope this helps!

Selenium iFrame input text

I am using Selenium to build a test automation where the html is in an iFrame, I was able to find online the lines of code to activate the iFrame, click on a link, and press a button and they are working fine -see following lines:
driver.SwitchTo().Frame("06634000000BVL6");
driver.FindElement(By.LinkText("Loan Details R1")).Click();
driver.FindElement(By.XPath("//button[contains(.,'Edit')]")).Click();
I needed to input a text within a textBox in that iFrame, but I couldn't handle the ID or the Class, below is the HTML for the input:
Any thoughts ?
Thanks for your help
I can't comment yet, so this will be part answer, part comment.
Based on what you have posted, it looks like you may not be in the correct iframe and we don't have enough of the code from the webpage to tell if there is an additional iframe.
I'd also like to see the code you are using to write text to the field, you may have an issue there.
If you don't and the only issue you have is the selector then try the following. Go get the developer version of firefox. Navigate to your webpage in firefox. Inspect the element where you want to write text to. Once you are in the inspection screen, there is a path bar that can scroll left and right at the bottom of the screen. Check that to confirm that there is only the one iframe you mentioned and that you are in the correct iframe. If that is the issue, you should be good to go, you're code above works for switching between frames. If you are in the right iframe, then try a different method of finding the element for the text box. I have had the most success with hard to find elements by using the cssselector. To get the cssselector for the element right click on it, navigate to copy and then cssselector. From there your code should look like this (using c#):
driver.FindElement(By.CssSelector("INSERT CSS SELECTOR HERE")).SendKeys("Text");

Inspect font/text of a pop-up bubble displayed when a required field is missing value - using Selenium WebDriver

Using Selenium-Java 2.47.1, I see this pop-up bubble/balloon that gets displayed whenever the 'submit' button is clicked and a required field is missing a value. I'm unable to inspect the bubble with firebug or DevTools. I need to be able to get the text and font.
Here is a link to an image of the bubble, it's very simple, I just can't seem to figure this out. Any help is appreciated, thanks!
In Firebug you can select Break On Mutate in the HTML tab (The pause button with brackets). Click the submit button, and Firebug will tell you what element is being added.

Select and mark part of text in android

i want to select some part of the text from text view using long press and drag. Basically am looking for a functionality like android pdf reader text selection. how can i implement this? after select some text i need to highlight it (color change/underline etc) .When i again visit the same page, app should show the content like i previously highlighted.
I saw the textview.setTextIsSelectable(true) option,
when i use this i can select the text, whats next? is this the proper method for this kind of task ? please help.
You should use
textView.setSelection(startIndex, endIndex);
instead

Categories

Resources