I have a page that contains a table with number of rows.
I need to work around a logic to which I need number of rows in that table
After searching in Google I found that findElements would do my work. When I tried this method I got a fatal error:
Fatal error:
Call to a member function findElements() on a non-object webDriver->findElements(\WebDriverBy::id("table-padding"));.
I just saw your question as I was looking for the same thing, I was able to do it in this way:
$I->executeInSelenium(function(\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver){ //Store current window id
global $meetings;
$meetings = $webdriver->findElements(WebDriverBy::cssselector('.today'));
});
I hope this can help you with your project.
It's much better to use $I->grabMultiple('.items', 'some_attribute')
https://codeception.com/docs/modules/PhpBrowser#grabMultiple
Another way is to use DOMDocument
$dom = new \DOMDocument();
#$dom->loadHTML($I->grabPageSource());
$xpath = new \DOMXPath($dom);
$elements = $xpath->query('.items');
$els = $this->getModule('WebDriver')->_findElements('.items');
_findElements
hidden API method, expected to be used from Helper classes
Locates element using available Codeception locator types:
XPath
CSS
Strict Locator
See more in docs
Related
I've worked on this for about 4 hours and I am real close but just missing the mark – here is what xml needs to look like
<ws:Answer QuestionID="Q_CAM_ID" ws:Datatype="string">
<ws:Value>6838</ws:Value>
</ws:Answer>
Here is what I get
<ns1:Answer QuestionID="Q_CAM_ID">
<ns1:Value>6838</ns1:Value>
</ns1:Answer>
Using
$A1 = new StdClass();
$A1->QuestionID = 'Q_CAM_ID';
$A1->Value =6838;
No matter what I try I can’t get “ws:Datatype="string"” to appear. I believe the answer is the below or real similar
$A1 = new StdClass();
$A1->QuestionID = new StdClass();
$A1->QuestionID->QuestionID ='Q_CAM_ID';
$A1->QuestionID->DataType ='string';
$A1->Value =6838;
But what I keep getting is this error
Catchable fatal error Object of class stdClass could not be converted to string when the soap call is done. If anyone has a clue I would be most appreciative
The simliest way to do it is to use a WSDL to php generator as you'll only deal with PHP object that matches the requires types. Moreover, if you a good WSDL to php generator, you'll have PHP classes that are named as the elements.
You could use https://www.wsdltophp.com or https://github.com/mikaelcom/WsdlToPhp.
Maybe I'm missing something but if you need that XML why not just make it as a String, and then convert it to what you are trying to do? If you are not using a WSDL or SimpleXML, I would just do the following.
$xml =
'
<ws:Answer QuestionID="Q_CAM_ID" ws:Datatype="string">
<ws:Value>6838</ws:Value>
</ws:Answer>
';
I am not certain if I am maybe misunderstanding, something in the examples I see, but any time I try to make sure of nsComplexObject, I get an error that it does not exist.
I am specifically trying to create a sales order. I set up my array of values, but when I try to do the following, I get an error:
<?php
require_once '../PHPToolkit/NetSuiteService.php';
$service = new NetSuiteService();
$salesOrder = new nsComplexObject('SalesOrder');
?>
I think you're looking at older Toolkit examples.
The newer versions (I think since 2012_2) use a different method for instantiating objects, such as:
$salesOrder = new SalesOrder();
You can still use the setFields method to populate object properties, but you can also populate them directly now:
$salesOrder->entity = $someRecordRefObject;
There are two pieces to this code:
One that adds documents to an index to be searched, which works fine, and a crawl() function that is a web-crawler that gets the contents of a page, which also works fine.
But, I need to add a document from inside the crawl() function.
When I move the code that adds a document inside the crawl() function, I get a Fatal Error:
Fatal Error: call to member function addDocument() on a non-object.
I am wondering how I can access the member function addDocument() from inside the crawl function?
Right now, I have a working version where the crawl() function returns what it has crawled in the form of a variable and then the addDocument code, outside the crawl() function, also has access to the returned variable and adds the document to the index that way.
But, that only (logically) works when I am crawling one page or a page with no links to follow. As the function only returns when it is done and since it is recursive to follow a page's links, the only content it will return is the content of the last-page.
Where I need the content of each page to be added each as a new document in the index.
Here is the working code, described above, commented as much as I could: http://pastebin.com/5ngcucDp
and here is the non-working code where I try to move the addDocument() inside the crawl() function: http://pastebin.com/mUEwQJTG
If you have a solution that involves how to access the addDocument() function from inside the crawl() function, then please share.
Or if you have a solution that involves modifying the working code so that it returns the contents of each page it crawls instead of the last-page, please share.
If you have any solutions, please share as I am absolutely exhausted and have tried everything I know.
When moving code to a function, you are completely removing its ability to access variables in the same scope. In this case, you probably (not going to go looking through your off-site code) have something like $someObject = new myClass();, then are trying to access $someObject->addDocument() on it from within the function.
You need to pass $someObject as a parameter to the function, or you could use global $someObject inside the function, though it's not as good an idea.
You have specified that:
// The below line is where the error takes place.
$elasticaType->addDocument($document);
Is your error line. Now, PHP is trying to access a class linked to $elasticaType If you have a linked class then use:
$elasticaType = new ClassName();
If not then you should create a class:
class Name {
public function addDocument ($document){
//Add document code
return $somevar;
}
}
$elasticaType = new Name();
$elasticaType->addDocument($document);
In my codeigniter i created a library in library folder.I want to load view pages in that library.How can i do this?
This is my code:
$this->load->view('view_page');
But when iam using this code i get an error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_theme_lib::$load
Filename: libraries/theme_lib.php
Line Number: 9
What is the problem in mycode?
In Line number 9 in library the code is :
$this->load->view('view_page');
To do what you're trying to do you need to get an instance of CI, and use that.
e.g.
$CI =& get_instance();
Within your library functions you could then use this variable to load the view:
$CI->load->view('view_page');
I would question though why you want to call a view, in the form that you have done, within a library. I suspect that you would be better to get the view call to return data (setting the 3rd parameter 'true') and then have your library return the display data to the controller.... Your approach seems messy, but then I have no idea what your library is trying to do.....
I have came across your question for different reason, I seem to have problem passing variables to views instead. Let me explain before I tell you answer to your problem.
Imagine you have an Emailer library to send emails rather than sorting that out in controller.
Emailer than within itself builds email string using views. My problem is that when I make my call from controller something like Emailer::send_mail($data,$template) it passes the variables correctly but when I do it from another library the view fails to register the variables. LOL
So yes Stéphane Bourzeix you do sometimes want to use output from view in a different way than just returning to client browser.
The solution is here.
https://www.codeigniter.com/userguide2/general/views.html
the last section of that page has something like
$string = $this->load->view('myfile', '', true);
but something like
$string = $this->load->view('myfile', $view_data, true);
should work too
in case of doing this from other places than controllers you will need to:
$this->ci = & get_instance();
$string = $this->ci->load->view("myfile",$view_data,true);
it seems like the last argument in the list (true) is the one that tells it not to render to browser but instead just create string with template content
I know it's a bit too late but hope it still helps to some. Good luck with your code.
tomhre
You simply DON'T load pages (aka Views) in a Library.
I don't see any need for doing this.
I know that you can use setVisibility('private-abcdefg') for newEventQuery() in order to specify a particular calendar.
My question is, can I use the same concept for newEventEntry()?
$gdataCal = new Zend_Gdata_Calendar($client);
$newEvent = $gdataCal->newEventEntry();
$newEvent->setVisibility('private-******************');
I tried out this code, but I receive the error:
Fatal error: Call to a member function getDOM() on a non-object in /home/content/b/e/h/behrk2/html/ZendGdata-1.8.4PL1/library/Zend/Gdata/Kind/EventEntry.php on line 154
Is there anything I can do to accomplish this? Because I have multiple Google Calendar's in one account, and I would like to specify which Calendar an event should go to...
Thanks!
You're overthinking it. I had the same exact problem, and it's simple, but not obvious, and took me some digging through the documentation to notice. To post to a calendar other than the default calendar, just add the uri to the other calendar to the insertEvent function at the end, like so:
$createdEvent = $gdataCal->insertEvent($newEvent, $uri);