Unable to inspect element by text value - c#

In the attached screenshot I want to read the value of title which is 'Title_6jOa'
But I'm unable to locate the element because text value is not present in highlighted area.
Any solution please.?

You should be able to locate the field by the class of the field, a CSS selector could be .x-frs-id-ivnt_Title
Then for reading the text that is typed into the field,
findElement(By.cssSelector(".x-frs-id-ivnt_Title")).getAttribute("value")
If the css selector .x-frs-id-ivnt_Title can't find the expected text box, try below xpath:
findElement(By.xpath("//tr[td[contains(., 'Title')]]/td/input")).getAttribute("value")
Please check the CSS selector and xpath manually in browser DevTool before change code.

Input Field Text values will not be be persisted in the Input Tag in Dev Tool.So,we cannot not use getText() Method and it can be extracted using the getAttribute() method as below or JavaScriptExecutor can be used (Using Selenium Web Driver to retrieve value of a HTML input)
Steps:
Identity the text field Web Element using any one of the unique locator
Use the getAttribute Method to get the value
Code :
WebElement titleInputElement=driver.findElement(By.xpath("//input[contains(#class,'x-frs-id-ivnt_Title')]"));
String value=titleInputElement.getAttribute("value");

#yong , #Subburaj Sorry tried yours way too, but getting no value.
Getting the value in below way perfectly.
Steps:
Double click in the text field. To get text selected.
Then copy the text to clipboard using Keyboard key ctrl+c
Copy the text
And Then the final step is reading the text from clipboard by below line of code in c#.
string clipboardExpectedText = System.Windows.Forms.Clipboard.GetText(System.Windows.Forms.TextDataFormat.Text);

Related

How can you fill a table cell using Selenium?

I'm trying to fill a table using the selenium drivers and all the documentations I could find only shows how to retrieve data from the cells. I'm able to access my table cells using:
var rows = Driver.FindElement(By.Id("Products")).FindElements(By.XPath("id('Products')/tbody/tr"));
var cells = tableRows[1].FindElements(By.XPath("td"));
But I couldn't find any way to update the data that's in it. The "Text" property only has a Get method and the SendKeys() function doesn't work. How can I edit the cell's value?
As a side note, my cell contains an html "input", I've tried to access it with the FindElement function of the cell but for some reasons it cannot find it.
Generally speaking, SendKeys should work if the cell indeed contains the input element. But because you're also saying that you fail to find the input element, I suspect that the input element does not exist in each cell all the time. You should probably first click on the cell in order for the input element to appear on that cell. You should be able to verify it using the Dev Tools if you inspect the element before clicking it.
IWebElement doesn't provide a method to change text, but you could use a little bit of JS - something little like :
((IJavaScriptExecutor)Driver).ExecuteScript("document.getElementByXXXXX.innerHTML = "VALUE";");
https://seleniumhq.github.io/selenium/docs/api/dotnet/html/M_OpenQA_Selenium_IJavaScriptExecutor_ExecuteScript.htm

How to check checkbox a pdf editor form using C#

This is my last hope please help me I am stuck with that check box in pdf editor.
I'm using iText library to generate pdf file based on template. But when I try to set checkbox field it won't filled. My code is below
form.SetField("topmostSubform[0].Page1[0].c1_01_0_[0]","1");
form.SetField("topmostSubform[0].Page1[0].c1_03_0_[0]", "true");
form.SetField("topmostSubform[0].Page1[0].c1_02_0_[0]", "2");
form.SetField("topmostSubform[0].Page1[0].c1_04_0_[0]", "On");
I have tried with following values
1) "Yes"
2) "1"
3) "true"
4) "On"
5) "2"
some one suggest me pass this value. I tried but this one also not working in my code.
Which value should I pass to set check box. Please help me and I referred this link also but it is not working.
The way you are setting the value is fine, but the value you are going to set should be matched with the Export Value
Q: how to find export value
Ans: If you can open the pdf in the Acrobat or any other pdf designer/editor
You can find its value by right click property ... Export Value
If Export Value is Y just set the value like
form.SetField("topmostSubform[0].Page1[0].c1_01_0_[0]","Y");
You already use 'Yes' for checkbox. I also filled pdf using ItextShap.
As per my knowledge, If you pass 'Yes' then it will check, you pass nothing then It will uncheck. Do one thing, Please share file with me.I will check in my code, after I will tell, what is the problem exactly.
Thanks .

Get hidden text of table rows using selenium webdriver?

My dropdown box is of type "Input" and its values are listed using table.I'm able to get the rows using following code.
WebElement table = driver.findElement(By.id("testTable"));
List<WebElement>tr_collection=table.findElements(By.xpath("id('testTable')/tbody/tr"));
Row text is retrieved only when the dropdown is clicked and text is displayed.Is it possible to get the text when it is hidden ?
The method WebElement.GetText() returns the text visible to a user. To get the hidden text, you can read the HTMLElement.textContent property. Though, I would recommend it in a testing context since it doesn't reflect a real usage.
To get the text with .GetAttribute:
string text = element.GetAttribute("textContent");
To get the text with .ExecuteScript:
string text = (string)driver.ExecuteScript("return arguments[0].textContent;", element);

How to change the Text value of a Telerik RichTextBox using c# and WinForms API

I am trying to set the text value of a RichTextBox by Telerik (ie. RadRichTextBox) to a value read from the database.
To set the value I tried the following which is not working "not setting the values"
InputDescription.Text = i._productDescription;
When I display the value of i._productDescription I do get results. So I am sure it is not empty/null and and the text box should have value.
How can I correctly set a text value to the RichTextBox?
Adding text in RadRichTextBox and RadRichTextEditor is done via importing, not with the Text property (although there is FR for this link).
Please refer to the following article which explains how you can import data in RadRichTextEditor: Import/Export | UI for WinForms Documentation.

How can I get the type of a textbox in watin?

I would like to get the type of the textbox using watin. Do we have any methods which can do this?
Suppose if we had two text boxes with name and phone number, we can get the value of the text box by using t.getValue();. There is no way to get what type of data it should contain as far as I know. t.getType() returns the IE instance.
Try t.GetAttributeValue("type").

Categories

Resources